-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Exhaustively handle expressions in patterns #134228
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @compiler-errors. Use |
HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in match checking cc @Nadrieril |
763003c
to
9af4537
Compare
HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in match checking cc @Nadrieril |
9af4537
to
42752cc
Compare
This comment has been minimized.
This comment has been minimized.
42752cc
to
7cee193
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot author |
7cee193
to
37cf874
Compare
This comment has been minimized.
This comment has been minimized.
37cf874
to
20f5e3f
Compare
We currently have this invariant in HIR that a
PatKind::Lit
or aPatKind::Range
only containsExprKind::Lit
ExprKind::UnOp(Neg, ExprKind::Lit)
ExprKind::Path
ExprKind::ConstBlock
So I made
PatKind::Lit
andPatKind::Range
stop containingExpr
, and instead created aPatLit
type whosekind
enum only contains those variants.The only place code got more complicated was in clippy, as it couldn't share as much anymore with
Expr
handlingIt may be interesting on merging
ExprKind::{Path,Lit,ConstBlock}
in the future and using the samePatLit
type (under a new name).Then it should also be easier to eliminate any and all
UnOp(Neg, Lit) | Lit
matching that we have across the compiler. Some day we should fold the negation into the literal itself and just store it on the numeric literals