diff --git a/tests/ui/match_same_arms.rs b/tests/ui/match_same_arms.rs index 8a7588f2e7f..5c65ea0a10c 100644 --- a/tests/ui/match_same_arms.rs +++ b/tests/ui/match_same_arms.rs @@ -108,6 +108,14 @@ fn match_same_arms() { (None, Some(a)) => bar(a), // bindings have different types _ => (), } + + let _ = match 42 { + 42 => 1, + 51 => 1, //~ ERROR match arms have same body + 41 => 2, + 52 => 2, //~ ERROR match arms have same body + _ => 0, + }; } fn main() {} diff --git a/tests/ui/match_same_arms.stderr b/tests/ui/match_same_arms.stderr index 9389e48a3e4..47440af2485 100644 --- a/tests/ui/match_same_arms.stderr +++ b/tests/ui/match_same_arms.stderr @@ -1,48 +1,10 @@ -error: this `match` has identical arm bodies - --> $DIR/match_same_arms.rs:37:14 - | -LL | _ => { - | ______________^ -LL | | //~ ERROR match arms have same body -LL | | foo(); -LL | | let mut a = 42 + [23].len() as i32; -... | -LL | | a -LL | | }, - | |_________^ - | - = note: `-D clippy::match-same-arms` implied by `-D warnings` -note: same as this - --> $DIR/match_same_arms.rs:28:15 - | -LL | 42 => { - | _______________^ -LL | | foo(); -LL | | let mut a = 42 + [23].len() as i32; -LL | | if true { -... | -LL | | a -LL | | }, - | |_________^ -note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/match_same_arms.rs:28:15 - | -LL | 42 => { - | _______________^ -LL | | foo(); -LL | | let mut a = 42 + [23].len() as i32; -LL | | if true { -... | -LL | | a -LL | | }, - | |_________^ - error: this `match` has identical arm bodies --> $DIR/match_same_arms.rs:52:14 | LL | _ => 0, //~ ERROR match arms have same body | ^ | + = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this --> $DIR/match_same_arms.rs:50:19 | @@ -139,5 +101,39 @@ note: consider refactoring into `(1, .., 3) | (.., 3)` LL | (1, .., 3) => 42, | ^^ -error: aborting due to 7 previous errors +error: this `match` has identical arm bodies + --> $DIR/match_same_arms.rs:114:15 + | +LL | 51 => 1, //~ ERROR match arms have same body + | ^ + | +note: same as this + --> $DIR/match_same_arms.rs:113:15 + | +LL | 42 => 1, + | ^ +note: consider refactoring into `42 | 51` + --> $DIR/match_same_arms.rs:113:15 + | +LL | 42 => 1, + | ^ + +error: this `match` has identical arm bodies + --> $DIR/match_same_arms.rs:116:15 + | +LL | 52 => 2, //~ ERROR match arms have same body + | ^ + | +note: same as this + --> $DIR/match_same_arms.rs:115:15 + | +LL | 41 => 2, + | ^ +note: consider refactoring into `41 | 52` + --> $DIR/match_same_arms.rs:115:15 + | +LL | 41 => 2, + | ^ + +error: aborting due to 8 previous errors