-
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
Allow leading | anywhere we allow or-patterns #81415
Comments
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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. |
Somehow to me they feel a little weirder in something like |
@scottmcm In that use case, they'd likely look like this: matches!(
some_long_expression,
| SomeLongPattern
| SomeOtherLongPattern
) |
@rfcbot reviewed |
Checking box for boats per rust-lang/team#526 . |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
This is what the grammar would look like after this change: https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2 |
Implementation: #81869 |
I think rustfmt should add a leading matches!(foo, Bar | Baz);
matches!(
some_really_long_expression,
| Bar
| Baz
)
match foo {
Bar | Baz => {},
_ => {}
}
match foo {
| Bar
| Baz => {},
_ => {}
} Just for consistency |
@lukechu10 Formatting is not something the compiler does. IIRC there is an issue about this on https://github.com/rust-lang/rustfmt somewhere. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
Simplify pattern grammar, improve or-pattern diagnostics This implements the change under FCP in rust-lang#81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2). Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc. r? `@petrochenkov`
Simplify pattern grammar, improve or-pattern diagnostics This implements the change under FCP in rust-lang#81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2). Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc. r? ``@petrochenkov``
Simplify pattern grammar, improve or-pattern diagnostics This implements the change under FCP in rust-lang#81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2). Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc. r? ```@petrochenkov```
Simplify pattern grammar, improve or-pattern diagnostics This implements the change under FCP in rust-lang#81415. It allows nested or-patterns to contain a leading `|`, simplifying the [grammar for patterns](https://github.com/rust-lang/reference/pull/957/files?short_path=cc629f1#diff-cc629f15712821139bc706c63b3845ab59a008e2a998e08ffad42e3aebcbcbe2). Along the way, we also improve the diagnostics around a few specially-handled cases, such as using `||` instead of `|`, using or-patterns in fn params, including the leading `|` in the pattern span, etc. r? `@petrochenkov`
Should this be closed now that the implementation is merged? |
Sounds good. |
See #54883 (comment) for details.
Filing this issue to check lang-team consensus on this: do we want to allow leading
|
everywhere we allow or-patterns?The text was updated successfully, but these errors were encountered: