Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion gcc/rust/typecheck/rust-tyty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,15 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate,
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, "expected %<%s%> got %<%s%>",
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 ());
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/issue-1725-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ pub fn foo<T: core::ops::Add<Output = i32>>(a: T) -> i32 {

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