]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
gccrs: Fix bad method resolution
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 17 Mar 2023 18:09:42 +0000 (18:09 +0000)
committerPhilip Herron <philip.herron@embecosm.com>
Sat, 18 Mar 2023 00:15:08 +0000 (00:15 +0000)
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>
gcc/rust/typecheck/rust-coercion.cc

index 7b91edfc73baeb80a782b235ce4c1b37758971de..4eb3746122eb3d8a58e0d4840dc8028f947ce837 100644 (file)
@@ -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;
 }