-
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
match_like_matches_macro lint could be improved a bit more #6186
Comments
This case will overlap with |
Hi, I'd like to hack on this. I think that every Now clippy suggests @ebroto what do you think about this trade-off? |
I think you're right. The main problem I can see with targeting more than two arms where one is wildcard is that we can have multiple if guards that could be difficult to "merge" in order to be used in
Not sure I got you here. You mean that in some cases |
Yeap, patterns with
Yeap, you got it right! I thought more and came to an idea that there are some issues about an order of patterns too. And I need a hard machinery from rustc (to check that I can reorder some patterns), it's hard to use from clippy. So the plan is triggering this lint for the following. match <...> {
<pat_0> => b0,
<pat_1> => b0,
...
<pat_k> => b0,
<pat_k+1> => b1,
...
<pat_n> => b1,
_ => b1,
} where And the question from my previous comment was about the last |
@alex-700 given that this is a warn-by-default lint, I think the safest approach for the moment would be a generalization of the initial comment in this issue: match <...> {
<pat_0> => b0,
<pat_1> => b0,
...
<pat_n> => b0,
_ => b1,
} What do you think? |
For example, this case doesn't warn:
But it could be improved using the
matches!
macro:The text was updated successfully, but these errors were encountered: