aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-08-15 22:24:10 +0500
committerPhilip Herron <philip.herron@embecosm.com>2023-08-28 17:32:19 +0000
commite493d7e0db925720e9b48c9b2fc329cc9b8c7a4e (patch)
tree0b858379dea5f046f02fd80ab41a2ebcf1ef2c3a /gcc
parent1b158384d65a7b1c19ddbad2cbecb5e7f4b671e1 (diff)
downloadgcc-e493d7e0db925720e9b48c9b2fc329cc9b8c7a4e.zip
gcc-e493d7e0db925720e9b48c9b2fc329cc9b8c7a4e.tar.gz
gcc-e493d7e0db925720e9b48c9b2fc329cc9b8c7a4e.tar.bz2
gccrs: [E0271] Type mismatch between associated type trait.
Added rich location and error code. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (BaseType::satisfies_bound): Added errorcode and user-friendly error message. gcc/testsuite/ChangeLog: * rust/compile/issue-1725-2.rs: Updated dejagnu message. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc9
-rw-r--r--gcc/testsuite/rust/compile/issue-1725-2.rs2
2 files changed, 9 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index d6ac115..4201688 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -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 ());
}
diff --git a/gcc/testsuite/rust/compile/issue-1725-2.rs b/gcc/testsuite/rust/compile/issue-1725-2.rs
index 01ed287..726d967 100644
--- a/gcc/testsuite/rust/compile/issue-1725-2.rs
+++ b/gcc/testsuite/rust/compile/issue-1725-2.rs
@@ -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 }
}