]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0271] Type mismatch between associated type trait.
authorMuhammad Mahad <mahadtxt@gmail.com>
Tue, 15 Aug 2023 17:24:10 +0000 (22:24 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:33 +0000 (19:00 +0100)
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>
gcc/rust/typecheck/rust-tyty.cc
gcc/testsuite/rust/compile/issue-1725-2.rs

index d5c1a4aca57ce087b234aedc9648b0e69c9d8247..2fbc1c176fe898567582a200c685011e898dc497 100644 (file)
@@ -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 ());
                    }
index 01ed287f545ec5d9ac44558363899db42a1f09c5..726d9677f11f5c8f32f4c15e19e4b1dd9dc7f8ff 100644 (file)
@@ -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 }
 }