From 405d9f1d135771015199546cd1c224ba589ab48d Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 3 Aug 2022 11:58:06 +0100 Subject: Fix ICE with duplicate hirid on autoderef coercion site mappings Imagine the call expression: Foo(a+b) But the a+b is an operator overload of the assignment operation. We store the autoderef coercions on the HIR id of the plus_expression here which is going to conflict with the id used to store the autoderef coercions the argument a+b. So this patch changes that all autoderef coercions store the autoderef for the implicit method call on the hirid of the lvalue hirid which in this case is 'a'. This means we won't conflict and cause an ICE in this case. --- gcc/rust/backend/rust-compile-expr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 92c224c..35861c1 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -1285,7 +1285,7 @@ CompileExpr::resolve_operator_overload ( // lookup the autoderef mappings std::vector *adjustments = nullptr; ok = ctx->get_tyctx ()->lookup_autoderef_mappings ( - expr.get_mappings ().get_hirid (), &adjustments); + expr.get_lvalue_mappings ().get_hirid (), &adjustments); rust_assert (ok); // apply adjustments for the fn call -- cgit v1.1