-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Reduce match
guard with equality with straightforward match
#11697
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
Comments
This lint already exists: Your example code has this warning:
|
And yes I have clippy lints turned on in my VSCode |
Looks like a false negative then. Smaller repro that doesn't emit any warnings, without the const X: i32 = 1;
match 1 {
x if x == X => {}
_ => {}
} |
Note that not all consts can be patterns and the precise semantics are being worked out. rust-lang/lang-team#220 Though in this case I would be surprised if anything stopped a const like this from working as a pattern. |
What it does
Prefer matching on the value directly instead of using a guard with equality
Advantage
No response
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: