-
Notifications
You must be signed in to change notification settings - Fork 155
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
Non-allowed default type paramters #2556
Conversation
gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Added more helpful error message. gcc/testsuite/ChangeLog: * rust/compile/generics10.rs: for dejagnu. Signed-off-by: Muhammad Mahad <[email protected]>
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.
LGTM
rich_location rich_locus (line_table, t.get_locus ()); | ||
rich_locus.add_fixit_replace ( | ||
t.get_locus (), "for more information, see issue #36887 " | ||
"<https://github.com/rust-lang/rust/" | ||
"issues/36887>"); | ||
rust_error_at (rich_locus, | ||
"defaults for type parameters are only " | ||
"allowed in %<struct%>, %<enum%>, %<type%>, " | ||
"or %<trait%> definitions"); |
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.
nice, it looks good! in a different PR, could you factor these lines in a separate function? this way we can modify the error message without changing it in two places
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.
@philberty left this issue to me to decide, whether to create a separate class for refactoring these errors.
But that seems excessive. What do you think, @CohenArthur? Should I create a separate class or add a refactor function when we encounter these cases?
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.
A separate class or a separate function is a good idea. I like both :)
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.
Okay :)
Non-allowed default
type
paramtersfixit
hint.gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: