]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/match_ref_pats.rs
2 #![warn(clippy::match_ref_pats)]
3 #![allow(dead_code, unused_variables, clippy::equatable_if_let, clippy::enum_variant_names)]
9 &Some(v
) => println
!("{:?}", v
),
10 &None
=> println
!("none"),
13 // This doesn't trigger; we have a different pattern.
14 &Some(v
) => println
!("some"),
15 other
=> println
!("other"),
20 &(v
, 1) => println
!("{}", v
),
21 _
=> println
!("none"),
23 // Special case: using `&` both in expr and pats.
26 &Some(v
) => println
!("{:?}", v
),
27 &None
=> println
!("none"),
29 // False positive: only wildcard pattern.
31 #[allow(clippy::match_single_binding)]
33 _
=> println
!("none"),
48 macro_rules
! foo_variant(
49 ($idx
:expr
) => (Foo
::get($idx
).unwrap())
58 fn get(idx
: u8) -> Option
<&'
static Self> {
69 match foo_variant
!(0) {
70 &Foo
::A
=> println
!("A"),
71 _
=> println
!("Wild"),
77 macro_rules
! foobar_variant(
78 ($idx
:expr
) => (FooBar
::get($idx
).unwrap())
89 fn get(idx
: u8) -> Option
<&'
static Self> {
91 0 => Some(&FooBar
::Foo
),
92 1 => Some(&FooBar
::Bar
),
93 2 => Some(&FooBar
::FooBar
),
94 3 => Some(&FooBar
::BarFoo
),
102 match foobar_variant
!(0) {
103 &FooBar
::Foo
=> println
!("Foo"),
104 &FooBar
::Bar
=> println
!("Bar"),
105 &FooBar
::FooBar
=> println
!("FooBar"),
106 _
=> println
!("Wild"),
109 // This shouldn't trigger
110 if let &FooBar
::BarFoo
= foobar_variant
!(3) {