-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
cc @rust-lang/lang |
Also related to #48501 |
☔ The latest upstream changes (presumably #48520) made this pull request unmergeable. Please resolve the merge conflicts. |
Indeed, I see no reason not to permit |
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.
r=me with nits addressed
src/libsyntax/parse/parser.rs
Outdated
-> 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)> { |
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.
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 `..`
@bors r=nikomatsakis |
📌 Commit c9aff92 has been approved by |
🌲 The tree is currently closed for pull requests below priority 200, this pull request will be tested once the tree is reopened |
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
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