]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: coercion sites allow for type inference as well.
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 3 Feb 2025 15:45:12 +0000 (15:45 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:07:01 +0000 (13:07 +0100)
Addresses Rust-GCC#3382 and Rust-GCC#3381

gcc/rust/ChangeLog:

* typecheck/rust-type-util.cc (coercion_site): allow inference vars

gcc/testsuite/ChangeLog:

* rust/compile/reference1.rs: fix error message

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-type-util.cc
gcc/testsuite/rust/compile/reference1.rs

index b7587526431fbe73b1bfea8295b8ab66e8661625..7a39eb53710fa69098f8097cc2863792f9fe7342 100644 (file)
@@ -217,8 +217,10 @@ coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
   rust_debug ("coerce_default_unify(a={%s}, b={%s})",
              receiver->debug_str ().c_str (), expected->debug_str ().c_str ());
   TyTy::BaseType *coerced
-    = unify_site (id, lhs, TyTy::TyWithLocation (receiver, rhs.get_locus ()),
-                 locus);
+    = unify_site_and (id, lhs,
+                     TyTy::TyWithLocation (receiver, rhs.get_locus ()), locus,
+                     true /*emit_error*/, true /*commit*/, true /*infer*/,
+                     true /*cleanup*/);
   context->insert_autoderef_mappings (id, std::move (result.adjustments));
   return coerced;
 }
index 2f94754bcb02014ec85d900deb698adba2609f04..28f7a262cc1bcbc3e35b61e09040dda972d705c2 100644 (file)
@@ -2,5 +2,5 @@ fn main() {
     let a = &123;
     let b: &mut i32 = a;
     // { dg-error "mismatched mutability" "" { target *-*-* } .-1 }
-    // { dg-error "mismatched types, expected .&mut i32. but got .& i32." "" { target *-*-* } .-2 }
+    // { dg-error "mismatched types, expected .&mut i32. but got .& <integer>." "" { target *-*-* } .-2 }
 }