1 #![warn(clippy::match_ref_pats)]
2 #![allow(clippy::equatable_if_let, clippy::enum_variant_names)]
8 &Some(v) => println!("{:?}", v),
9 &None => println!("none"),
12 // This doesn't trigger; we have a different pattern.
13 &Some(v) => println!("some"),
14 other => println!("other"),
19 &(v, 1) => println!("{}", v),
20 _ => println!("none"),
22 // Special case: using `&` both in expr and pats.
25 &Some(v) => println!("{:?}", v),
26 &None => println!("none"),
28 // False positive: only wildcard pattern.
30 #[allow(clippy::match_single_binding)]
32 _ => println!("none"),
47 macro_rules! foo_variant(
48 ($idx:expr) => (Foo::get($idx).unwrap())
57 fn get(idx: u8) -> Option<&'static Self> {
68 match foo_variant!(0) {
69 &Foo::A => println!("A"),
70 _ => println!("Wild"),
76 macro_rules! foobar_variant(
77 ($idx:expr) => (FooBar::get($idx).unwrap())
88 fn get(idx: u8) -> Option<&'static Self> {
90 0 => Some(&FooBar::Foo),
91 1 => Some(&FooBar::Bar),
92 2 => Some(&FooBar::FooBar),
93 3 => Some(&FooBar::BarFoo),
101 match foobar_variant!(0) {
102 &FooBar::Foo => println!("Foo"),
103 &FooBar::Bar => println!("Bar"),
104 &FooBar::FooBar => println!("FooBar"),
105 _ => println!("Wild"),
108 // This shouldn't trigger
109 if let &FooBar::BarFoo = foobar_variant!(3) {