-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Amend RFC 2175 to support for loops and leading vert #2530
Conversation
I agree that this RFC extended irrefutable patterns to allow @rfcbot fcp merge |
Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
With my style team hat on, I don't think we should recommend using leading vert in any of these places. However, I don't have any objection allowing this if it drastically simplify the grammar. That said, @Centril, can you please show how this simplifies the grammar enough to be worthwhile? |
In full agreement wrt. style recommendations :)
Certainly! Here goes a review of grammatical simplifications: The status quo (i.e. with RFC 2071) is that we have (formulated for maximum clarity):
what this PR does is unify first bits of the grammar so that we get:
since these are all equivalent, our grammar becomes just:
I would not call this simplification drastic, but it is simplification that makes the language have less corner cases and thus makes it easier for users to understand. Another benefit is that macros in particular have an easier time when you avoid syntactic corner cases. As a note about style, observe that match foo {
| A => {},
| B => {},
| C => {},
} into: match foo {
A => {},
B => {},
C => {},
} The rustfmt tool should, for consistency, apply this rule for any leading |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. |
This PR fixes RFC 2175 to also:
|
(already inmatch
expressions)for
loops (where the or-pattern must be irrefutable as inlet
bindings).This is more or less a consistency bug-fix.
Elaboration on grammatical consistency and simplification in #2530 (comment).