Skip to content
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

Merged
merged 1 commit into from
Jan 24, 2017

Conversation

theduke
Copy link
Contributor

@theduke theduke commented Jan 10, 2017

Part of the work for #38830 .

r? @steveklabnik

@rust-highfive
Copy link
Collaborator

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 ] ? ] *
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ?

Copy link
Contributor Author

@theduke theduke Jan 10, 2017

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 ] * 

Copy link
Member

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.

Copy link
Contributor Author

@theduke theduke Jan 10, 2017

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.

@theduke theduke force-pushed the document-field-init-shorthand-38830 branch 2 times, most recently from 90b69c1 to 7620271 Compare January 10, 2017 11:35
@nagisa
Copy link
Member

nagisa commented Jan 10, 2017

This LGTM.

@theduke theduke force-pushed the document-field-init-shorthand-38830 branch from 7620271 to 487ca5c Compare January 10, 2017 12:09
@nikomatsakis nikomatsakis mentioned this pull request Jan 11, 2017
5 tasks
@steveklabnik
Copy link
Member

@bors: r+ rollup

sorry for the tardiness here!

@bors
Copy link
Contributor

bors commented Jan 23, 2017

📌 Commit 487ca5c has been approved by steveklabnik

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jan 23, 2017
…nd-38830, r=steveklabnik

Update struct_expr grammar for field init shorthand.

Part of the work for rust-lang#38830 .

r? @steveklabnik
bors added a commit that referenced this pull request Jan 23, 2017
Rollup of 7 pull requests

- Successful merges: #38794, #38956, #38993, #39191, #39200, #39233, #39258
- Failed merges:
@bors bors merged commit 487ca5c into rust-lang:master Jan 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants