File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1769,17 +1769,12 @@ void Converter::ConvertIntegralToBooleanCast(clang::ImplicitCastExpr *expr) {
17691769 }
17701770}
17711771
1772- bool Converter::IsSameRustType (clang::Expr *a, clang::Expr *b) {
1773- auto get_converted_type_or_mapped_type = [&](clang::Expr *expr) {
1774- if (!clang::isa<clang::ImplicitCastExpr>(expr)) {
1775- if (const auto *rule = Mapper::GetExprRule (expr)) {
1776- return rule->return_type .type ;
1777- }
1778- }
1779- return GetUnsafeTypeAsString (expr->getType ());
1780- };
1781- return get_converted_type_or_mapped_type (a) ==
1782- get_converted_type_or_mapped_type (b);
1772+ bool Converter::IsCastRedundantInRust (clang::Expr *expr, clang::QualType target_type) {
1773+ auto target = GetUnsafeTypeAsString (target_type);
1774+ if (const auto *rule = Mapper::GetExprRule (expr)) {
1775+ return rule->return_type .type == target;
1776+ }
1777+ return GetUnsafeTypeAsString (expr->getType ()) == target;
17831778}
17841779
17851780bool Converter::VisitImplicitCastExpr (clang::ImplicitCastExpr *expr) {
@@ -1879,7 +1874,7 @@ bool Converter::VisitImplicitCastExpr(clang::ImplicitCastExpr *expr) {
18791874 break ;
18801875 }
18811876 // Skip cast if source and target map to the same Rust type.
1882- if (IsSameRustType (sub_expr, expr )) {
1877+ if (IsCastRedundantInRust (sub_expr, type )) {
18831878 Convert (sub_expr);
18841879 break ;
18851880 }
Original file line number Diff line number Diff line change @@ -686,7 +686,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
686686
687687 TempMaterializationCtx CollectPrvalueToLRefArgs (clang::CallExpr *expr);
688688
689- bool IsSameRustType (clang::Expr *a , clang::Expr *b );
689+ bool IsCastRedundantInRust (clang::Expr *expr , clang::QualType target_type );
690690
691691private:
692692 void materializeTemplateSpecialization (clang::CXXRecordDecl *decl);
You can’t perform that action at this time.
0 commit comments