Skip to content

Commit 646ad25

Browse files
committed
Move constructor has priority over copyable
1 parent a538ea2 commit 646ad25

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4617,9 +4617,6 @@ std::string Converter::ConvertPlaceholder(clang::Expr *expr, clang::Expr *arg,
46174617
}
46184618
if (auto *record = arg->getType()->getAsCXXRecordDecl();
46194619
record && IsUserDefinedDecl(record)) {
4620-
if (TypeIsCopyable(arg->getType())) {
4621-
return ConvertRValue(arg);
4622-
}
46234620
for (auto *ctor : record->ctors()) {
46244621
if (!IsUserDefinedMoveConstructor(ctor)) {
46254622
continue;
@@ -4628,6 +4625,9 @@ std::string Converter::ConvertPlaceholder(clang::Expr *expr, clang::Expr *arg,
46284625
Convert(MakeConstructExpr(ctx_, arg->getType(), ctor, arg));
46294626
return std::move(buf).str();
46304627
}
4628+
if (TypeIsCopyable(arg->getType())) {
4629+
return ConvertRValue(arg);
4630+
}
46314631
return ConvertFreshRValue(arg);
46324632
}
46334633
return std::format("std::mem::take(&mut {})", ConvertLValue(arg));

0 commit comments

Comments
 (0)