File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1779,17 +1779,12 @@ void Converter::ConvertIntegralToBooleanCast(clang::ImplicitCastExpr *expr) {
17791779 }
17801780}
17811781
1782- bool Converter::IsSameRustType (clang::Expr *a, clang::Expr *b) {
1783- auto get_converted_type_or_mapped_type = [&](clang::Expr *expr) {
1784- if (!clang::isa<clang::ImplicitCastExpr>(expr)) {
1785- if (const auto *rule = Mapper::GetExprRule (expr)) {
1786- return rule->return_type .type ;
1787- }
1788- }
1789- return GetUnsafeTypeAsString (expr->getType ());
1790- };
1791- return get_converted_type_or_mapped_type (a) ==
1792- get_converted_type_or_mapped_type (b);
1782+ bool Converter::IsCastRedundantInRust (clang::Expr *expr, clang::QualType target_type) {
1783+ auto target = GetUnsafeTypeAsString (target_type);
1784+ if (const auto *rule = Mapper::GetExprRule (expr)) {
1785+ return rule->return_type .type == target;
1786+ }
1787+ return GetUnsafeTypeAsString (expr->getType ()) == target;
17931788}
17941789
17951790bool Converter::VisitImplicitCastExpr (clang::ImplicitCastExpr *expr) {
@@ -1891,7 +1886,7 @@ bool Converter::VisitImplicitCastExpr(clang::ImplicitCastExpr *expr) {
18911886 break ;
18921887 }
18931888 // Skip cast if source and target map to the same Rust type.
1894- if (IsSameRustType (sub_expr, expr )) {
1889+ if (IsCastRedundantInRust (sub_expr, type )) {
18951890 Convert (sub_expr);
18961891 break ;
18971892 }
Original file line number Diff line number Diff line change @@ -706,7 +706,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
706706
707707 TempMaterializationCtx CollectPrvalueToLRefArgs (clang::CallExpr *expr);
708708
709- bool IsSameRustType (clang::Expr *a , clang::Expr *b );
709+ bool IsCastRedundantInRust (clang::Expr *expr , clang::QualType target_type );
710710
711711private:
712712 void materializeTemplateSpecialization (clang::CXXRecordDecl *decl);
You can’t perform that action at this time.
0 commit comments