From: Philip Herron <[email protected]>
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 <[email protected]>
---
gcc/rust/typecheck/rust-tyty.cc | 33 ++++------------------
gcc/testsuite/rust/compile/issue-1725-2.rs | 3 +-
2 files changed, 7 insertions(+), 29 deletions(-)
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<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 }
}
--
2.50.1