]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: remove 2nd last usage of can_eq
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 29 Aug 2025 15:52:34 +0000 (16:52 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:57 +0000 (20:58 +0100)
gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (BaseType::satisfies_bound): use types_compatable instead

gcc/testsuite/ChangeLog:

* rust/compile/issue-1725-2.rs: remove bad error message

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-tyty.cc
gcc/testsuite/rust/compile/issue-1725-2.rs

index 1803f9cd1effe8e47cc41ff1de1a5bfbd2045c38..411191806aa4a8568d5fd931bebf51d4dd01462e 100644 (file)
@@ -358,33 +358,12 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate, bool emit_error)
          const auto *item_ref = lookup->get_raw_item ();
          TyTy::BaseType *bound_ty = item_ref->get_tyty ();
 
-         // compare the types
-         if (!bound_ty->can_eq (impl_item_ty, false))
-           {
-             if (!impl_item_ty->can_eq (bound_ty, false))
-               {
-                 if (emit_error)
-                   {
-                     rich_location r (line_table,
-                                      mappings.lookup_location (get_ref ()));
-                     r.add_range (predicate.get_locus ());
-                     r.add_range (mappings.lookup_location (i.get_hirid ()));
-
-                     std::string rich_msg
-                       = "expected " + bound_ty->destructure ()->get_name ()
-                         + ", found "
-                         + impl_item_ty->destructure ()->get_name ();
-                     r.add_fixit_replace (rich_msg.c_str ());
-
-                     rust_error_at (
-                       r, ErrorCode::E0271,
-                       "type mismatch, expected %qs but got %qs",
-                       bound_ty->destructure ()->get_name ().c_str (),
-                       impl_item_ty->destructure ()->get_name ().c_str ());
-                   }
-                 return false;
-               }
-           }
+         if (!Resolver::types_compatable (
+               TyTy::TyWithLocation (bound_ty, predicate.get_locus ()),
+               TyTy::TyWithLocation (impl_item_ty, item->get_locus ()),
+               mappings.lookup_location (get_ref ()), false /*emit-error*/,
+               false /*check-bounds*/))
+           return false;
        }
 
       return true;
index 726d9677f11f5c8f32f4c15e19e4b1dd9dc7f8ff..d6a2d686c05e8701ecda25039799805aa72c4d7e 100644 (file)
@@ -26,6 +26,5 @@ pub fn foo<T: core::ops::Add<Output = i32>>(a: T) -> i32 {
 
 pub fn main() {
     foo(123f32);
-    // { dg-error "type mismatch, expected .i32. but got .f32." "" { target *-*-* } .-1 }
-    // { dg-error "bounds not satisfied for f32 .Add. is not satisfied" "" { target *-*-* } .-2 }
+    // { dg-error "bounds not satisfied for f32 .Add. is not satisfied" "" { target *-*-* } .-1 }
 }