-
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 matchable if let
for pattern
#9221
Comments
We can use |
if let
for patternif let
for pattern
Also, the logic would also be similar to |
@rustbot claim |
@dswij 👋 May I ask if you meant that we should add the new linting within |
I haven't taken a deep look into it, but if we plan to add this to a new lint, we can factor out reusable logic from |
Thanks. I'll take a deeper look at the 2 lints that you've written down and circle back when I have a clearer picture :) |
@dswij It seems that |
it seems like it won't fire if Makes sense since if So I think this is more of an improvement - if it doesn't implement |
@dswij Thanks for the tip. I was trying to understand this lint but had some trouble yesterday. Does your suggestion mean that if is_structural_partial_eq returns |
Yes, exactly. Suggest I'm trying to think of scenarios where suggesting |
Will do! I'll start adding some new test cases and do the improvement. Maybe by the time of review we'd think of more edge cases. |
@nahuakang Excuse me if this is a wrong place to ask, but after this change to the if let (None, None) = (&self.x, &self.y) { into if matches!((&self.x, &self.y), (None, None)) { which I would consider worse. Otherwise How do I properly request a feature or open a discussion for this? |
What it does
Checks for
if let
forpattern
s that can be re-written withmatches!
This can be an improvement to
equatable_if_let
lint.For background see #9102 (comment)
Lint Name
No response
Category
No response
Advantage
Similar to
equatable_if_let
:Drawbacks
No response
Example
can be written as
The text was updated successfully, but these errors were encountered: