public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Fix ICE in audodref mappings when argument is a method call
@ 2022-08-06 12:10 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-08-06 12:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:79d0f29464fc0aa68af7b317964aff4bc35af59a

commit 79d0f29464fc0aa68af7b317964aff4bc35af59a
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Thu Aug 4 16:13:52 2022 +0100

    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.

Diff:
---
 gcc/rust/backend/rust-compile-expr.cc          | 6 ++++--
 gcc/rust/typecheck/rust-hir-type-check-expr.cc | 8 ++++++--
 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 35861c12d9c..8576cf2fd19 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 c328f410c6c..9c31284060e 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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-06 12:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-06 12:10 [gcc/devel/rust/master] Fix ICE in audodref mappings when argument is a method call Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).