public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7943] gccrs: [E0271] Type mismatch between associated type trait.
@ 2024-01-16 18:09 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0e65b1f9b377eb6a2464905c4060dc86d972d9d9
commit r14-7943-g0e65b1f9b377eb6a2464905c4060dc86d972d9d9
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date: Tue Aug 15 22:24:10 2023 +0500
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>
Diff:
---
gcc/rust/typecheck/rust-tyty.cc | 9 ++++++++-
gcc/testsuite/rust/compile/issue-1725-2.rs | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index d5c1a4aca57..2fbc1c176fe 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 01ed287f545..726d9677f11 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 }
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:09 [gcc r14-7943] gccrs: [E0271] Type mismatch between associated type trait Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).