-
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
Lint for generalizeable captures #10530
Comments
See also rust-lang/rust#109489 where I found instances of this in rustc. |
@rustbot label: +good-first-issue |
@rustbot claim |
I think unnested_or_patterns should already handle this, or is it different because |
Hmm good point about unnested_or_patterns. I have tried enabling all the clippy lints before I filed the issue but it didn't show up, not sure what went wrong back then.
Closing as it's already implemented in clippy. |
What it does
Take this code:
The binding
w
of the first arm's pattern is repeated three times. One can simplify the pattern as follows:Lint Name
repetitive_capture
Category
style
Advantage
This saves repetition of the binding (less chars) and makes the code more maintainable as renames only affect one site instead of multiple
Drawbacks
It adds one layer of
()
s, but this should be bearableExample
provided above
The text was updated successfully, but these errors were encountered: