[gcc r14-7381] gccrs: Fix bad method resolution

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 17:27:18 GMT 2024


https://gcc.gnu.org/g:6d169ce149a3af1d50ea36345a4e26805535a989

commit r14-7381-g6d169ce149a3af1d50ea36345a4e26805535a989
Author: Philip Herron <herron.philip@googlemail.com>
Date:   Fri Mar 17 18:09:42 2023 +0000

    gccrs: Fix bad method resolution
    
    We should use the result of our attempted unify inference as this will
    allow the direct unification of generic pointer types to concrete ones.
    
    Fixes #1981
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-coercion.cc (TypeCoercionRules::select): use the result
    
    Signed-off-by: Philip Herron <herron.philip@googlemail.com>

Diff:
---
 gcc/rust/typecheck/rust-coercion.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/typecheck/rust-coercion.cc b/gcc/rust/typecheck/rust-coercion.cc
index b5d6cef2f79..2cc71967511 100644
--- a/gcc/rust/typecheck/rust-coercion.cc
+++ b/gcc/rust/typecheck/rust-coercion.cc
@@ -413,9 +413,9 @@ TypeCoercionRules::coerce_unsized (TyTy::BaseType *source,
 bool
 TypeCoercionRules::select (TyTy::BaseType &autoderefed)
 {
-  rust_debug (
-    "autoderef type-coercion select autoderefed={%s} can_eq expected={%s}",
-    autoderefed.debug_str ().c_str (), expected->debug_str ().c_str ());
+  rust_debug ("TypeCoercionRules::select autoderefed={%s} can_eq expected={%s}",
+	      autoderefed.debug_str ().c_str (),
+	      expected->debug_str ().c_str ());
 
   TyTy::BaseType *result
     = unify_site_and (autoderefed.get_ref (), TyTy::TyWithLocation (expected),
@@ -426,7 +426,7 @@ TypeCoercionRules::select (TyTy::BaseType &autoderefed)
   if (!ok)
     return false;
 
-  try_result = CoercionResult{adjustments, autoderefed.clone ()};
+  try_result = CoercionResult{adjustments, result};
   return true;
 }


More information about the Gcc-cvs mailing list