Skip to content

Commit 8f5512f

Browse files
Copilotnunoplopes
andauthored
Fix spurious reinterpret_cast insertion caused by whitespace mismatch in ConvertPointeeType
Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
1 parent c5bbd6b commit 8f5512f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ std::string Converter::ConvertPointeeType(clang::QualType ptr_type) {
119119
assert(!ptr_type.isNull() && ptr_type->isPointerType());
120120
auto pointee = ptr_type->getPointeeType();
121121
if (!pointee->isRecordType()) {
122-
return ToString(pointee);
122+
return std::string(Trim(ToString(pointee)));
123123
}
124124

125125
auto str = ToString(ptr_type);
126126
Unwrap(str, "*mut ", "");
127127
Unwrap(str, "*const ", "");
128-
return str;
128+
return std::string(Trim(str));
129129
}
130130

131131
bool Converter::VisitBuiltinType(clang::BuiltinType *type) {

‎cpp2rust/converter/models/converter_refcount.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,7 +2584,7 @@ std::string ConverterRefCount::ConvertPointeeType(clang::QualType ptr_type) {
25842584
PushConversionKind push(*this, ConversionKind::Unboxed);
25852585
auto pointee = ptr_type->getPointeeType();
25862586
if (!pointee->isRecordType()) {
2587-
return ToString(pointee);
2587+
return std::string(Trim(ToString(pointee)));
25882588
}
25892589

25902590
// Pointee of a pointer to incomplete type is an incomplete type that does
@@ -2593,7 +2593,7 @@ std::string ConverterRefCount::ConvertPointeeType(clang::QualType ptr_type) {
25932593
auto str = ToString(ptr_type);
25942594
Unwrap(str, "PtrDyn<", ">");
25952595
Unwrap(str, "Ptr<", ">");
2596-
return str;
2596+
return std::string(Trim(str));
25972597
}
25982598

25992599
bool ConverterRefCount::ShouldConvertMethod(const clang::CXXMethodDecl *decl) {

0 commit comments

Comments
 (0)