-
Notifications
You must be signed in to change notification settings - Fork 1.7k
match_same_arms
: FP if arms have different comments
#12044
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
@rustbot claim |
I got the basic code ready but am facing trouble with the UI tests: let _ = match Abc::A {
Abc::A => 0, //~ ERROR: this match arm has an identical body to the `_` wildcard arm
Abc::B => 1,
_ => 0,
}; The comment marking the error causes the lint to not raise any error in this part. There are several such occurrences in the UI tests. Any suggestions on how to overcome this issue? |
@ARandomDev99 you can open a draft, and it'd be easier for us to help. What do you mean with:
|
let _ = match Abc::A {
Abc::A => 0, //~ ERROR: this match arm has an identical body to the `_` wildcard arm
Abc::B => 1,
_ => 0,
}; I'll try to explain it the best I can. The comment here marks the expected message the emitted lint will display. However, the changes I've made take comments into account while deciding if two match arms are same or not which results in the UI test failing as these two arms have different comments and will not emit any lint. |
Okay I see. You can tell the error comment how many lines above the error is using
|
@partiallytyped thank you! |
#12060 (comment) While modifying |
I don't know off-hand which lints would benefit from ignoring comments. Generally they only match simple expressions which don't contain blocks anyways so it's not that big of a deal. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
match_same_arms
lints on two arms, if the comments are different.Lint Name
match_same_arms
Reproducer
I tried this code:
Playground
I saw this happen:
I expected to see this happen:
No warning
Version
Additional Labels
These utils might be good to look at:
@rustbot label +good-first-issue
The text was updated successfully, but these errors were encountered: