3 #![feature(custom_inner_attributes)]
4 #![warn(clippy::match_like_matches_macro)]
5 #![allow(unreachable_patterns, dead_code, clippy::equatable_if_let)]
11 let _y = matches!(x, Some(0));
14 let _w = matches!(x, Some(_));
20 let _zz = !matches!(x, Some(r) if r == 0);
23 let _zzz = matches!(x, Some(5));
47 let _ans = matches!(x, E::A(_) | E::B(_));
51 // skip rustfmt to prevent removing block for first pattern
53 let _ans = matches!(x, E::A(_) | E::B(_));
57 let _ans = !matches!(x, E::B(_) | E::C);
80 E::A(a) if a < 10 => false,
81 E::B(a) if a < 10 => false,
89 E::B(a) if a < 10 => false,
111 // should print "z" in suggestion (#6503)
113 let _z = matches!(z, Some(3));
117 // this could also print "z" in suggestion..?
119 let _z = matches!(&z, Some(3));
128 fn foo(_x: AnEnum) {}
132 // we can't remove the reference here!
133 let _ = matches!(&z, AnEnum::X);
141 fn fun(_val: Option<S>) {}
142 let val = Some(S(42));
143 // we need the reference here because later val is consumed by fun()
144 let _res = matches!(&val, &Some(ref _a));
151 fn fun(_val: Option<S>) {}
152 let val = Some(S(42));
153 let _res = matches!(&val, &Some(ref _a));
166 #[cfg(feature = "foo")]
173 // ignore if match block contains comment
174 let _line_comments = match x {
176 '1' | '2' | '3' => true,
177 // spaces are very important to be true.
184 let _block_comments = match x {
187 '1' | '2' | '3' => true,
188 /* spaces are very important to be true.
199 #![clippy::msrv = "1.41"]
201 let _y = match Some(5) {
208 #![clippy::msrv = "1.42"]
210 let _y = matches!(Some(5), Some(0));