1 #![warn(clippy::match_same_arms)]
2
3 pub enum Abc {
4 A,
5 B,
6 C,
7 }
8
match_same_arms()9 fn match_same_arms() {
10 let _ = match Abc::A {
11 Abc::A => 0,
12 Abc::B => 1,
13 _ => 0, //~ ERROR match arms have same body
14 };
15
16 match (1, 2, 3) {
17 (1, .., 3) => 42,
18 (.., 3) => 42, //~ ERROR match arms have same body
19 _ => 0,
20 };
21
22 let _ = match 42 {
23 42 => 1,
24 51 => 1, //~ ERROR match arms have same body
25 41 => 2,
26 52 => 2, //~ ERROR match arms have same body
27 _ => 0,
28 };
29
30 let _ = match 42 {
31 1 => 2,
32 2 => 2, //~ ERROR 2nd matched arms have same body
33 3 => 2, //~ ERROR 3rd matched arms have same body
34 4 => 3,
35 _ => 0,
36 };
37 }
38
39 mod issue4244 {
40 #[derive(PartialEq, PartialOrd, Eq, Ord)]
41 pub enum CommandInfo {
42 BuiltIn { name: String, about: Option<String> },
43 External { name: String, path: std::path::PathBuf },
44 }
45
46 impl CommandInfo {
name(&self) -> String47 pub fn name(&self) -> String {
48 match self {
49 CommandInfo::BuiltIn { name, .. } => name.to_string(),
50 CommandInfo::External { name, .. } => name.to_string(),
51 }
52 }
53 }
54 }
55
main()56 fn main() {}
57