-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[E0323] Implemented associated const, expected another trait #2445
Conversation
if (!found || raw_trait_item->is_error ()) | ||
{ | ||
rich_location r (line_table, constant.get_locus ()); | ||
r.add_range (trait_reference.get_locus ()); | ||
rust_error_at (r, "constant %<%s%> is not a member of trait %<%s%>", | ||
rust_error_at (r, ErrorCode ("E0323"), | ||
"item %<%s%> is an associated const, which does not match " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Refactored Error message, similiar to rustc.
- With a little difference,
- The diff of rustc and gccrs error is:
# gccrs
+ item ‘N’ is an associated const, which does not match its trait ‘Foo’
- item `N` is an associated const, which doesn't match its trait `Foo`
Is there a way to add single apostrophe, in the error message:
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-implitem.cc:398:68: warning: bare apostrophe ‘'’ in format [-Wformat-diag]
398 | "item %<%s%> is an associated const, which doe's not match "
| ^
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-implitem.cc:398:22: note: if avoiding the apostrophe is not feasible, enclose it in a pair of ‘%<’ and ‘%>’ directives instead
398 | "item %<%s%> is an associated const, which doe's not match "
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399 | "its trait %<%s%>",
| ~~~~~~~~~~~~~~~~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the grammar you used is correct, no need to add a single apostrophe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CohenArthur, Yeah there is no need to add a single apostrophe. But it would be better to add, then the whole message will be exactly similiar to rustc..
if (!found || raw_trait_item->is_error ()) | ||
{ | ||
rich_location r (line_table, constant.get_locus ()); | ||
r.add_range (trait_reference.get_locus ()); | ||
rust_error_at (r, "constant %<%s%> is not a member of trait %<%s%>", | ||
rust_error_at (r, ErrorCode ("E0323"), | ||
"item %<%s%> is an associated const, which does not match " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the grammar you used is correct, no need to add a single apostrophe?
if (!found || raw_trait_item->is_error ()) | ||
{ | ||
rich_location r (line_table, constant.get_locus ()); | ||
r.add_range (trait_reference.get_locus ()); | ||
rust_error_at (r, "constant %<%s%> is not a member of trait %<%s%>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked this error message a little more personally :D but that's just nitpicking haha
Refactored Error message similiar to rustc. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItemWithTrait::visit): called error function. gcc/testsuite/ChangeLog: * rust/compile/non_member_const.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
@CohenArthur We accidently merged wrong error message & error code in this PR :( The error code should be |
that's okay, good catch! can you open an issue so we don't forget to address it? |
Const is not member of trait
E0323
Code tested from
E0323
:Output:
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: