Skip to content

Commit f912f91

Browse files
committed
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 <[email protected]>
1 parent fd14a31 commit f912f91

File tree

2 files changed

+7
-29
lines changed

2 files changed

+7
-29
lines changed

gcc/rust/typecheck/rust-tyty.cc

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -358,33 +358,12 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate, bool emit_error)
358358
const auto *item_ref = lookup->get_raw_item ();
359359
TyTy::BaseType *bound_ty = item_ref->get_tyty ();
360360

361-
// compare the types
362-
if (!bound_ty->can_eq (impl_item_ty, false))
363-
{
364-
if (!impl_item_ty->can_eq (bound_ty, false))
365-
{
366-
if (emit_error)
367-
{
368-
rich_location r (line_table,
369-
mappings.lookup_location (get_ref ()));
370-
r.add_range (predicate.get_locus ());
371-
r.add_range (mappings.lookup_location (i.get_hirid ()));
372-
373-
std::string rich_msg
374-
= "expected " + bound_ty->destructure ()->get_name ()
375-
+ ", found "
376-
+ impl_item_ty->destructure ()->get_name ();
377-
r.add_fixit_replace (rich_msg.c_str ());
378-
379-
rust_error_at (
380-
r, ErrorCode::E0271,
381-
"type mismatch, expected %qs but got %qs",
382-
bound_ty->destructure ()->get_name ().c_str (),
383-
impl_item_ty->destructure ()->get_name ().c_str ());
384-
}
385-
return false;
386-
}
387-
}
361+
if (!Resolver::types_compatable (
362+
TyTy::TyWithLocation (bound_ty, predicate.get_locus ()),
363+
TyTy::TyWithLocation (impl_item_ty, item->get_locus ()),
364+
mappings.lookup_location (get_ref ()), false /*emit-error*/,
365+
false /*check-bounds*/))
366+
return false;
388367
}
389368

390369
return true;

gcc/testsuite/rust/compile/issue-1725-2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ pub fn foo<T: core::ops::Add<Output = i32>>(a: T) -> i32 {
2626

2727
pub fn main() {
2828
foo(123f32);
29-
// { dg-error "type mismatch, expected .i32. but got .f32." "" { target *-*-* } .-1 }
30-
// { dg-error "bounds not satisfied for f32 .Add. is not satisfied" "" { target *-*-* } .-2 }
29+
// { dg-error "bounds not satisfied for f32 .Add. is not satisfied" "" { target *-*-* } .-1 }
3130
}

0 commit comments

Comments
 (0)