]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: fix ICE with inserting autoderef mappings
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 30 Jun 2023 21:08:10 +0000 (22:08 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:30 +0000 (18:49 +0100)
We were using the call-expr id for the autoderef mappings but this doesn't
work when the call expression itself is part of a coercion-site so this
changes the code to use the call-expression function path expression for
the id instead which will not be duplicated again.

Addresses #2105

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::generate_possible_fn_trait_call): use fnexpr
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_fn_trait_call): likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/backend/rust-compile-expr.cc
gcc/rust/typecheck/rust-hir-type-check-expr.cc

index eaf4a672bc19c26a730b4ddf8272bc4fb43c6135..ed425ed7e14512650934d238516bb380b54625b3 100644 (file)
@@ -2893,7 +2893,8 @@ CompileExpr::generate_possible_fn_trait_call (HIR::CallExpr &expr,
     }
 
   // need to apply any autoderef's to the self argument
-  HirId autoderef_mappings_id = expr.get_mappings ().get_hirid ();
+  HIR::Expr *fnexpr = expr.get_fnexpr ();
+  HirId autoderef_mappings_id = fnexpr->get_mappings ().get_hirid ();
   std::vector<Resolver::Adjustment> *adjustments = nullptr;
   bool ok = ctx->get_tyctx ()->lookup_autoderef_mappings (autoderef_mappings_id,
                                                          &adjustments);
index 3379c5e957dc7a0de93e6bb66e5dc929c08861e7..9d44939d22eb38587d68faf98a1a8994ec603a1b 100644 (file)
@@ -1910,7 +1910,8 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr,
   // store the adjustments for code-generation to know what to do which must be
   // stored onto the receiver to so as we don't trigger duplicate deref mappings
   // ICE when an argument is a method call
-  HirId autoderef_mappings_id = expr.get_mappings ().get_hirid ();
+  HIR::Expr *fnexpr = expr.get_fnexpr ();
+  HirId autoderef_mappings_id = fnexpr->get_mappings ().get_hirid ();
   context->insert_autoderef_mappings (autoderef_mappings_id,
                                      std::move (candidate.adjustments));
   context->insert_receiver (expr.get_mappings ().get_hirid (), receiver_tyty);