Skip to content

Commit aa387ab

Browse files
committed
from_string_literal already appends null byte
1 parent 4088095 commit aa387ab

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

‎cpp2rust/converter/models/converter_refcount.cpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,9 +1329,8 @@ bool ConverterRefCount::VisitCallExpr(clang::CallExpr *expr) {
13291329
}
13301330

13311331
std::string ConverterRefCount::GetSourceFileAsString(clang::QualType type) {
1332-
return std::format(
1333-
"Ptr::<{}>::from_string_literal(concat!(file!(), \"\\0\").as_bytes())",
1334-
ToStringBase(type->getPointeeType().getUnqualifiedType()));
1332+
return std::format("Ptr::<{}>::from_string_literal(file!().as_bytes())",
1333+
ToStringBase(type->getPointeeType().getUnqualifiedType()));
13351334
}
13361335

13371336
bool ConverterRefCount::VisitStringLiteral(clang::StringLiteral *expr) {

‎tests/unit/out/refcount/macros.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ fn main_0() -> i32 {
6262
assert!((line!() as u32 > 0_u32));
6363
assert!(
6464
(((elem!(
65-
({
66-
base_name_0(Ptr::<i8>::from_string_literal(
67-
concat!(file!(), "\0").as_bytes(),
68-
))
69-
}),
65+
({ base_name_0(Ptr::<i8>::from_string_literal(file!().as_bytes()),) }),
7066
0
7167
)
7268
.read()) as i32)

0 commit comments

Comments
 (0)