aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-08-04 16:13:52 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-08-04 16:52:52 +0100
commit79d0f29464fc0aa68af7b317964aff4bc35af59a (patch)
tree8bc08398524b309e1e2e4e19862c7dbd145e9341
parent6f88307147ac7b63c315aab2e81811e985a867a7 (diff)
downloadgcc-79d0f29464fc0aa68af7b317964aff4bc35af59a.zip
gcc-79d0f29464fc0aa68af7b317964aff4bc35af59a.tar.gz
gcc-79d0f29464fc0aa68af7b317964aff4bc35af59a.tar.bz2
Fix ICE in audodref mappings when argument is a method call
Similar to the fix in 405d9f1d135771015199546cd1c224ba589ab48d when we have arguments that our method calls. The id used for storing the autoderef mappings being the method call itself rather than the receiver argument it will cause an ICE when we are type checking all arguments for the case of: Foo(a, bar.baz(123)) This ensures we store the autoderef mappings directly on the reciever instead.
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc6
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.cc8
2 files changed, 10 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 35861c1..8576cf2 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1035,9 +1035,11 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
}
// lookup the autoderef mappings
+ HirId autoderef_mappings_id
+ = expr.get_receiver ()->get_mappings ().get_hirid ();
std::vector<Resolver::Adjustment> *adjustments = nullptr;
- ok = ctx->get_tyctx ()->lookup_autoderef_mappings (
- expr.get_mappings ().get_hirid (), &adjustments);
+ ok = ctx->get_tyctx ()->lookup_autoderef_mappings (autoderef_mappings_id,
+ &adjustments);
rust_assert (ok);
// apply adjustments for the fn call
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index c328f41..9c31284 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -324,8 +324,12 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
Adjuster adj (receiver_tyty);
TyTy::BaseType *adjusted_self = adj.adjust_type (candidate.adjustments);
- // store the adjustments for code-generation to know what to do
- context->insert_autoderef_mappings (expr.get_mappings ().get_hirid (),
+ // 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_receiver ()->get_mappings ().get_hirid ();
+ context->insert_autoderef_mappings (autoderef_mappings_id,
std::move (candidate.adjustments));
PathProbeCandidate &resolved_candidate = candidate.candidate;