From: Philip Herron Date: Fri, 29 Aug 2025 15:52:34 +0000 (+0100) Subject: gccrs: remove 2nd last usage of can_eq X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83df8ca5020c7d7fb753d92052a972ed56e37e09;p=thirdparty%2Fgcc.git gccrs: remove 2nd last usage of can_eq 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 --- diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 1803f9cd1ef..411191806aa 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -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; diff --git a/gcc/testsuite/rust/compile/issue-1725-2.rs b/gcc/testsuite/rust/compile/issue-1725-2.rs index 726d9677f11..d6a2d686c05 100644 --- a/gcc/testsuite/rust/compile/issue-1725-2.rs +++ b/gcc/testsuite/rust/compile/issue-1725-2.rs @@ -26,6 +26,5 @@ pub fn foo>(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 } }