-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Update struct_expr grammar for field init shorthand. #38956
Update struct_expr grammar for field init shorthand. #38956
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (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. |
struct_expr : expr_path '{' ident ':' expr | ||
[ ',' ident ':' expr ] * | ||
struct_expr : expr_path '{' ident [ ':' expr ] ? | ||
[ ',' [ ident [ ':' expr ] ? ] * |
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.
This is incorrect.
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.
Why ?
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.
You mean it should be :
ident | ident ':' expr
?
This might be a bit cleaner:
struct_expr_field_init : ident | ident ':' expr
struct_expr : expr_path '{' struct_expr_field_init
[ ',' struct_expr_field_init ] *
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.
Braces are not balanced (and there’s the same mistake in the cleaner version as well). Extracting into struct_expr_field_init
sounds like a good idea regardless. Makes it easier to read.
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.
Ah yeah, I obvisouly should have noticed that, I was a bit hasty. My bad.
Should be fixed now.
90b69c1
to
7620271
Compare
This LGTM. |
7620271
to
487ca5c
Compare
@bors: r+ rollup sorry for the tardiness here! |
📌 Commit 487ca5c has been approved by |
…nd-38830, r=steveklabnik Update struct_expr grammar for field init shorthand. Part of the work for rust-lang#38830 . r? @steveklabnik
Part of the work for #38830 .
r? @steveklabnik