]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Make the coerce borrowed pointer consistent with try flag
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 25 Aug 2025 19:44:16 +0000 (20:44 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:53 +0000 (20:58 +0100)
This interface is not respecting the coercion api commit is always false,
we need to ensure this is respected via the try flag like the rest of the
coercion logic.

gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::select): respect try flag

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-coercion.cc

index 2b023ed0edd2645f8e34141409d99df39eb2145d..e027d9c88c6c423f26a85146f16ed59b6a4ae7fc 100644 (file)
@@ -439,7 +439,8 @@ TypeCoercionRules::select (TyTy::BaseType &autoderefed)
     = unify_site_and (autoderefed.get_ref (), TyTy::TyWithLocation (expected),
                      TyTy::TyWithLocation (&autoderefed),
                      UNDEF_LOCATION /* locus */, false /*emit_errors*/,
-                     false /*commit_if_ok*/, true /*infer*/, true /*cleanup*/);
+                     !try_flag /*commit_if_ok*/, try_flag /*infer*/,
+                     try_flag /*cleanup*/);
   bool ok = result->get_kind () != TyTy::TypeKind::ERROR;
   if (!ok)
     return false;