-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Exhaustively handle expressions in patterns #134228
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -623,7 +623,7 @@ impl Pat { | |
PatKind::Wild | ||
| PatKind::Rest | ||
| PatKind::Never | ||
| PatKind::Lit(_) | ||
| PatKind::Expr(_) | ||
| PatKind::Range(..) | ||
| PatKind::Ident(..) | ||
| PatKind::Path(..) | ||
|
@@ -801,8 +801,8 @@ pub enum PatKind { | |
/// A reference pattern (e.g., `&mut (a, b)`). | ||
Ref(P<Pat>, Mutability), | ||
|
||
/// A literal. | ||
Lit(P<Expr>), | ||
/// A literal, const block or path. | ||
Expr(P<Expr>), | ||
Comment on lines
+804
to
+805
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oli-obk so the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it always contained these. I'm working towards making that explicit. I wasn't going to touch the ast immediately, but considering that non-lit variants slipped into rustfmt without notice, I should probably do it sooner. Until then we can just make rustfmt match exhaustively on lit/neg(lit)/constblock/path and panic in the other cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had no idea that was the case. Well, thanks for clearing that up. |
||
|
||
/// A range pattern (e.g., `1...2`, `1..2`, `1..`, `..2`, `1..=2`, `..=2`). | ||
Range(Option<P<Expr>>, Option<P<Expr>>, Spanned<RangeEnd>), | ||
|
Uh oh!
There was an error while loading. Please reload this page.