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

Support parentheses in patterns under feature gate #48500

Merged
merged 1 commit into from
Mar 2, 2018

Conversation

petrochenkov
Copy link
Contributor

This is a prerequisite for any other extensions to pattern syntax - | with multiple patterns, type ascription, ..PAT in slice patterns.

Closes rust-lang/rfcs#554

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 24, 2018
@petrochenkov
Copy link
Contributor Author

cc @rust-lang/lang
r? @nikomatsakis

@petrochenkov
Copy link
Contributor Author

Also related to #48501

@kennytm kennytm added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Feb 24, 2018
@bors
Copy link
Contributor

bors commented Feb 25, 2018

☔ The latest upstream changes (presumably #48520) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2018
@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 25, 2018
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Feb 26, 2018

Indeed, I see no reason not to permit () in patterns. Surprised we don't already. I guess we never needed it before.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

r=me with nits addressed

-> PResult<'a, (Vec<P<Pat>>, Option<usize>)> {
let mut fields = vec![];
let mut ddpos = None;
fn parse_pat_tuple(&mut self) -> PResult<'a, (Vec<P<Pat>>, Option<usize>, bool)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd prefer a name like parse_pat_parenthesized_list. Also, a comment explaining this would be nice. Something like:


Parses a parenthesized list of patterns like (), (p), (p,), (p, q), or (p, q, ..). Returns a vector of the subpatterns that were parsed, along with (a) an option indicating the index of the .. element and (b) a boolean indicating whether a trailing comma was present. Trailing commas are significant because (p) and (p,) are different patterns.

Improve recovery for trailing comma after `..`
@petrochenkov
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 28, 2018

📌 Commit c9aff92 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 28, 2018

🌲 The tree is currently closed for pull requests below priority 200, this pull request will be tested once the tree is reopened

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 1, 2018
Support parentheses in patterns under feature gate

This is a prerequisite for any other extensions to pattern syntax - `|` with multiple patterns, type ascription, `..PAT` in slice patterns.

Closes rust-lang/rfcs#554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants