-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
accept union pseudo keyword inside enum #66965
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
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.
Thanks for the contribution! I've left a couple of small comments.
src/librustc_parse/parser/item.rs
Outdated
@@ -1739,7 +1739,8 @@ impl<'a> Parser<'a> { | |||
fn recover_nested_adt_item(&mut self, keyword: Symbol) -> PResult<'a, bool> { | |||
if self.token.is_keyword(kw::Enum) || | |||
self.token.is_keyword(kw::Struct) || | |||
self.token.is_keyword(kw::Union) | |||
self.token.is_keyword(kw::Union) && | |||
self.look_ahead(1, |t| t.is_ident()) |
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.
self.look_ahead(1, |t| t.is_ident()) | |
self.next_tok().is_ident() |
I'm not sure if this is equivalent, but it might be worth trying if you haven't.
src/test/ui/enum/union-in-enum.rs
Outdated
@@ -0,0 +1,5 @@ | |||
enum A { union } //~ WARNING |
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.
Adding // check-pass
would be good here, since we don't need to test codegen and linking for this (and we expect the test to pass, not fail, which would fix the current CI failure).
@@ -0,0 +1,40 @@ | |||
warning: variant `union` should have an upper camel case name |
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.
Could you #![allow(..)]
these warnings in the test? They aren't relevant to what this is testing.
src/test/ui/enum/union-in-enum.rs
Outdated
@@ -0,0 +1,5 @@ | |||
enum A { union } //~ WARNING |
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.
Could you add a comment here explaining what this is testing? Just something like:
This test checks that the
union
keyword is accepted as the name of an enum variant when not followed by an identifier.
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 was really stucked in testcase part.
.It is my first contribution.
Thank you for all your suggestions.
Fixes #66943