2 #![warn(clippy::match_ref_pats)]
3 #![allow(dead_code, unused_variables)]
4 #![allow(clippy::enum_variant_names, clippy::equatable_if_let, clippy::uninlined_format_args)]
10 &Some(v) => println!("{:?}", v),
11 &None => println!("none"),
14 // This doesn't trigger; we have a different pattern.
15 &Some(v) => println!("some"),
16 other => println!("other"),
21 &(v, 1) => println!("{}", v),
22 _ => println!("none"),
24 // Special case: using `&` both in expr and pats.
27 &Some(v) => println!("{:?}", v),
28 &None => println!("none"),
30 // False positive: only wildcard pattern.
32 #[allow(clippy::match_single_binding)]
34 _ => println!("none"),
49 macro_rules! foo_variant(
50 ($idx:expr) => (Foo::get($idx).unwrap())
59 fn get(idx: u8) -> Option<&'static Self> {
70 match foo_variant!(0) {
71 &Foo::A => println!("A"),
72 _ => println!("Wild"),
78 macro_rules! foobar_variant(
79 ($idx:expr) => (FooBar::get($idx).unwrap())
90 fn get(idx: u8) -> Option<&'static Self> {
92 0 => Some(&FooBar::Foo),
93 1 => Some(&FooBar::Bar),
94 2 => Some(&FooBar::FooBar),
95 3 => Some(&FooBar::BarFoo),
103 match foobar_variant!(0) {
104 &FooBar::Foo => println!("Foo"),
105 &FooBar::Bar => println!("Bar"),
106 &FooBar::FooBar => println!("FooBar"),
107 _ => println!("Wild"),
110 // This shouldn't trigger
111 if let &FooBar::BarFoo = foobar_variant!(3) {