You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #13803 together with @blyxyas we discovered that match_same_arms does not deal with cases where more than 2 arms have the same body. E.g. this test:
2 => 2,//~ ERROR: this match arm has an identical body to another arm
//~^ ERROR: this match arm has an identical body to another arm
3 => 2,//~ ERROR: this match arm has an identical body to another arm
4 => 3,
_ => 0,
};
Will generate two overlapping suggestions - one to combine 1 and 2, one to combine 2 and 3. This means the lint cannot be automatically applied, and @rust-nofix remains.
It looks like the issue is that the arms are matched up pairwise, rather than collecting all that have the same body and suggesting an aggregate fix:
Summary
In #13803 together with @blyxyas we discovered that
match_same_arms
does not deal with cases where more than 2 arms have the same body. E.g. this test:rust-clippy/tests/ui/match_same_arms.rs
Lines 31 to 38 in 6a3ef93
Will generate two overlapping suggestions - one to combine 1 and 2, one to combine 2 and 3. This means the lint cannot be automatically applied, and
@rust-nofix
remains.It looks like the issue is that the arms are matched up pairwise, rather than collecting all that have the same body and suggesting an aggregate fix:
rust-clippy/clippy_lints/src/matches/match_same_arms.rs
Lines 115 to 116 in 6a3ef93
We should change this to aggregate all equivalent bodies and provide a single suggestion to combine them.
Reproducer
Remove
@rust-nofix
frommatch_same_arms
and check out the overlapping application failure for the test code linked above.Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: