-
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
Remove unnecessary match #7040
Comments
It would be better for categories to be |
@giraffate |
|
Okay. Will change it |
Can someone estimate how complex implementing this lint is? |
I think this should be Name idea:
This should be quite easy to implement. You just need to check that, for each match arm, the body of the arm is the same as the pattern. Not quite as simple as |
Oh, it make sense. |
How do I go about implementing this? |
If I'm not mistaken, correctness lints error instead of warn. We should really add the "suspicious" lint group we suggested earlier. |
@SaadiSave have you looked at the contributing docs? |
Since no one has claim this in almost a year, so I'll give it a try. @rustbot claim |
new lint that detects useless match expression fixes #7040 changelog: - Register new `correctness` lint called `nop_match` - add basic test cases - add logic to check for unnecessary match - add logic to check for unnecessary if-let expressions, remove some test cases because checking them will take a lot extra effort TODO: - ~~detects unnecessary match~~ - ~~detects unnecessary if-let expression that similar to match~~ - modify `question_mark` and `manual_map` to solve possible confliction
What it does
What does this lint do?
Remove unnecessary match for error handling when function signatures are the same.
Categories (optional)
style
,correctness
?What is the advantage of the recommended code over the original code
Not sure if there are any performance improvements. The code is more readable and shorter though. This lint also applies for any function pair that returns the same enum, like
Option<T>
for example.Drawbacks
None.
Example
Could be written as:
Real world example
The text was updated successfully, but these errors were encountered: