@@ -6,10 +6,18 @@ LL | let _y = match x {
66LL | | Some(0) => true,
77LL | | _ => false,
88LL | | };
9- | |_____^ help: try: `matches!(x, Some(0))`
9+ | |_____^
1010 |
1111 = note: `-D clippy::match-like-matches-macro` implied by `-D warnings`
1212 = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]`
13+ help: use `matches!` directly
14+ |
15+ LL - let _y = match x {
16+ LL - Some(0) => true,
17+ LL - _ => false,
18+ LL - };
19+ LL + let _y = matches!(x, Some(0));
20+ |
1321
1422error: redundant pattern matching, consider using `is_some()`
1523 --> tests/ui/match_like_matches_macro.rs:20:14
@@ -42,13 +50,28 @@ LL | let _zz = match x {
4250LL | | Some(r) if r == 0 => false,
4351LL | | _ => true,
4452LL | | };
45- | |_____^ help: try: `!matches!(x, Some(r) if r == 0)`
53+ | |_____^
54+ |
55+ help: use `matches!` directly
56+ |
57+ LL - let _zz = match x {
58+ LL - Some(r) if r == 0 => false,
59+ LL - _ => true,
60+ LL - };
61+ LL + let _zz = !matches!(x, Some(r) if r == 0);
62+ |
4663
47- error: if let .. else expression looks like `matches!` macro
64+ error: ` if let .. else` expression looks like `matches!` macro
4865 --> tests/ui/match_like_matches_macro.rs:41:16
4966 |
5067LL | let _zzz = if let Some(5) = x { true } else { false };
51- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(x, Some(5))`
68+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69+ |
70+ help: use `matches!` directly
71+ |
72+ LL - let _zzz = if let Some(5) = x { true } else { false };
73+ LL + let _zzz = matches!(x, Some(5));
74+ |
5275
5376error: match expression looks like `matches!` macro
5477 --> tests/ui/match_like_matches_macro.rs:66:20
@@ -59,7 +82,17 @@ LL | | E::A(_) => true,
5982LL | | E::B(_) => true,
6083LL | | _ => false,
6184LL | | };
62- | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))`
85+ | |_________^
86+ |
87+ help: use `matches!` directly
88+ |
89+ LL - let _ans = match x {
90+ LL - E::A(_) => true,
91+ LL - E::B(_) => true,
92+ LL - _ => false,
93+ LL - };
94+ LL + let _ans = matches!(x, E::A(_) | E::B(_));
95+ |
6396
6497error: match expression looks like `matches!` macro
6598 --> tests/ui/match_like_matches_macro.rs:77:20
@@ -71,7 +104,19 @@ LL | | true
71104... |
72105LL | | _ => false,
73106LL | | };
74- | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))`
107+ | |_________^
108+ |
109+ help: use `matches!` directly
110+ |
111+ LL - let _ans = match x {
112+ LL - E::A(_) => {
113+ LL - true
114+ LL - }
115+ LL - E::B(_) => true,
116+ LL - _ => false,
117+ LL - };
118+ LL + let _ans = matches!(x, E::A(_) | E::B(_));
119+ |
75120
76121error: match expression looks like `matches!` macro
77122 --> tests/ui/match_like_matches_macro.rs:88:20
@@ -82,7 +127,17 @@ LL | | E::B(_) => false,
82127LL | | E::C => false,
83128LL | | _ => true,
84129LL | | };
85- | |_________^ help: try: `!matches!(x, E::B(_) | E::C)`
130+ | |_________^
131+ |
132+ help: use `matches!` directly
133+ |
134+ LL - let _ans = match x {
135+ LL - E::B(_) => false,
136+ LL - E::C => false,
137+ LL - _ => true,
138+ LL - };
139+ LL + let _ans = !matches!(x, E::B(_) | E::C);
140+ |
86141
87142error: match expression looks like `matches!` macro
88143 --> tests/ui/match_like_matches_macro.rs:149:18
@@ -92,7 +147,16 @@ LL | let _z = match &z {
92147LL | | Some(3) => true,
93148LL | | _ => false,
94149LL | | };
95- | |_________^ help: try: `matches!(z, Some(3))`
150+ | |_________^
151+ |
152+ help: use `matches!` directly
153+ |
154+ LL - let _z = match &z {
155+ LL - Some(3) => true,
156+ LL - _ => false,
157+ LL - };
158+ LL + let _z = matches!(z, Some(3));
159+ |
96160
97161error: match expression looks like `matches!` macro
98162 --> tests/ui/match_like_matches_macro.rs:159:18
@@ -102,7 +166,16 @@ LL | let _z = match &z {
102166LL | | Some(3) => true,
103167LL | | _ => false,
104168LL | | };
105- | |_________^ help: try: `matches!(&z, Some(3))`
169+ | |_________^
170+ |
171+ help: use `matches!` directly
172+ |
173+ LL - let _z = match &z {
174+ LL - Some(3) => true,
175+ LL - _ => false,
176+ LL - };
177+ LL + let _z = matches!(&z, Some(3));
178+ |
106179
107180error: match expression looks like `matches!` macro
108181 --> tests/ui/match_like_matches_macro.rs:177:21
@@ -112,7 +185,16 @@ LL | let _ = match &z {
112185LL | | AnEnum::X => true,
113186LL | | _ => false,
114187LL | | };
115- | |_____________^ help: try: `matches!(&z, AnEnum::X)`
188+ | |_____________^
189+ |
190+ help: use `matches!` directly
191+ |
192+ LL - let _ = match &z {
193+ LL - AnEnum::X => true,
194+ LL - _ => false,
195+ LL - };
196+ LL + let _ = matches!(&z, AnEnum::X);
197+ |
116198
117199error: match expression looks like `matches!` macro
118200 --> tests/ui/match_like_matches_macro.rs:192:20
@@ -122,7 +204,16 @@ LL | let _res = match &val {
122204LL | | &Some(ref _a) => true,
123205LL | | _ => false,
124206LL | | };
125- | |_________^ help: try: `matches!(&val, &Some(ref _a))`
207+ | |_________^
208+ |
209+ help: use `matches!` directly
210+ |
211+ LL - let _res = match &val {
212+ LL - &Some(ref _a) => true,
213+ LL - _ => false,
214+ LL - };
215+ LL + let _res = matches!(&val, &Some(ref _a));
216+ |
126217
127218error: match expression looks like `matches!` macro
128219 --> tests/ui/match_like_matches_macro.rs:205:20
@@ -132,7 +223,16 @@ LL | let _res = match &val {
132223LL | | &Some(ref _a) => true,
133224LL | | _ => false,
134225LL | | };
135- | |_________^ help: try: `matches!(&val, &Some(ref _a))`
226+ | |_________^
227+ |
228+ help: use `matches!` directly
229+ |
230+ LL - let _res = match &val {
231+ LL - &Some(ref _a) => true,
232+ LL - _ => false,
233+ LL - };
234+ LL + let _res = matches!(&val, &Some(ref _a));
235+ |
136236
137237error: match expression looks like `matches!` macro
138238 --> tests/ui/match_like_matches_macro.rs:264:14
@@ -142,7 +242,16 @@ LL | let _y = match Some(5) {
142242LL | | Some(0) => true,
143243LL | | _ => false,
144244LL | | };
145- | |_____^ help: try: `matches!(Some(5), Some(0))`
245+ | |_____^
246+ |
247+ help: use `matches!` directly
248+ |
249+ LL - let _y = match Some(5) {
250+ LL - Some(0) => true,
251+ LL - _ => false,
252+ LL - };
253+ LL + let _y = matches!(Some(5), Some(0));
254+ |
146255
147256error: aborting due to 14 previous errors
148257
0 commit comments