Skip to content

Commit cfc51d4

Browse files
committed
gccrs: fix ICE with inserting autoderef mappings
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 <[email protected]>
1 parent 251348f commit cfc51d4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

gcc/rust/backend/rust-compile-expr.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2893,7 +2893,8 @@ CompileExpr::generate_possible_fn_trait_call (HIR::CallExpr &expr,
28932893
}
28942894

28952895
// need to apply any autoderef's to the self argument
2896-
HirId autoderef_mappings_id = expr.get_mappings ().get_hirid ();
2896+
HIR::Expr *fnexpr = expr.get_fnexpr ();
2897+
HirId autoderef_mappings_id = fnexpr->get_mappings ().get_hirid ();
28972898
std::vector<Resolver::Adjustment> *adjustments = nullptr;
28982899
bool ok = ctx->get_tyctx ()->lookup_autoderef_mappings (autoderef_mappings_id,
28992900
&adjustments);

gcc/rust/typecheck/rust-hir-type-check-expr.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,8 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr,
19101910
// store the adjustments for code-generation to know what to do which must be
19111911
// stored onto the receiver to so as we don't trigger duplicate deref mappings
19121912
// ICE when an argument is a method call
1913-
HirId autoderef_mappings_id = expr.get_mappings ().get_hirid ();
1913+
HIR::Expr *fnexpr = expr.get_fnexpr ();
1914+
HirId autoderef_mappings_id = fnexpr->get_mappings ().get_hirid ();
19141915
context->insert_autoderef_mappings (autoderef_mappings_id,
19151916
std::move (candidate.adjustments));
19161917
context->insert_receiver (expr.get_mappings ().get_hirid (), receiver_tyty);

0 commit comments

Comments
 (0)