Description
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
from match_same_arms
and check out the overlapping application failure for the test code linked above.
Version
Additional Labels
No response