1 #![warn(clippy::single_match)]
17 // Note the missing block braces.
18 // We suggest `if let Some(y) = x { .. }` because the macro
19 // is expanded before we can do anything.
20 Some(y) => println!("{:?}", y),
26 (2..=3, 7..=9) => dummy(),
30 // Not linted (pattern guards used)
32 Some(y) if y == 0 => println!("{:?}", y),
36 // Not linted (no block with statements in the single arm)
38 (2..=3, 7..=9) => println!("{:?}", z),
39 _ => println!("nope"),
50 fn single_match_know_enum() {
52 let y: Result<_, i8> = Ok(1i8);
64 let c = Cow::Borrowed("");
67 Cow::Borrowed(..) => dummy(),
74 Bar => println!("42"),
79 Baz(_) => println!("42"),
92 #[derive(PartialEq, Eq)]
101 Foo::A => println!(),
105 const FOO_C: Foo = Foo::C(0);
112 Foo::A => println!(),
118 Foo::A => println!(),
126 impl PartialEq for Bar {
127 fn eq(&self, rhs: &Self) -> bool {
128 matches!((self, rhs), (Self::A, Self::A) | (Self::B, Self::B))
135 Bar::A => println!(),
148 macro_rules! single_match {
151 15 => println!("15"),