Skip to content

Commit 970f46c

Browse files
committed
Add tests
1 parent 8ace7ea commit 970f46c

File tree

3 files changed

+176
-32
lines changed

3 files changed

+176
-32
lines changed

tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr

+85-16
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,36 @@ LL | match_no_arms!(0u8);
77
= note: the matched value is of type `u8`
88
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
99

10-
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
10+
error[E0004]: non-exhaustive patterns: type `i8` is non-empty
1111
--> $DIR/empty-match.rs:47:20
1212
|
13+
LL | match_no_arms!(0i8);
14+
| ^^^
15+
|
16+
= note: the matched value is of type `i8`
17+
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
18+
19+
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
20+
--> $DIR/empty-match.rs:48:20
21+
|
22+
LL | match_no_arms!(0usize);
23+
| ^^^^^^
24+
|
25+
= note: the matched value is of type `usize`
26+
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
27+
28+
error[E0004]: non-exhaustive patterns: type `isize` is non-empty
29+
--> $DIR/empty-match.rs:49:20
30+
|
31+
LL | match_no_arms!(0isize);
32+
| ^^^^^^
33+
|
34+
= note: the matched value is of type `isize`
35+
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
36+
37+
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
38+
--> $DIR/empty-match.rs:50:20
39+
|
1340
LL | match_no_arms!(NonEmptyStruct1);
1441
| ^^^^^^^^^^^^^^^
1542
|
@@ -22,7 +49,7 @@ LL | struct NonEmptyStruct1;
2249
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
2350

2451
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
25-
--> $DIR/empty-match.rs:48:20
52+
--> $DIR/empty-match.rs:51:20
2653
|
2754
LL | match_no_arms!(NonEmptyStruct2(true));
2855
| ^^^^^^^^^^^^^^^^^^^^^
@@ -36,7 +63,7 @@ LL | struct NonEmptyStruct2(bool);
3663
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
3764

3865
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
39-
--> $DIR/empty-match.rs:49:20
66+
--> $DIR/empty-match.rs:52:20
4067
|
4168
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
4269
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,7 +77,7 @@ LL | union NonEmptyUnion1 {
5077
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
5178

5279
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
53-
--> $DIR/empty-match.rs:50:20
80+
--> $DIR/empty-match.rs:53:20
5481
|
5582
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
5683
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -64,7 +91,7 @@ LL | union NonEmptyUnion2 {
6491
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
6592

6693
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
67-
--> $DIR/empty-match.rs:51:20
94+
--> $DIR/empty-match.rs:54:20
6895
|
6996
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
7097
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@@ -80,7 +107,7 @@ LL | Foo(bool),
80107
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
81108

82109
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
83-
--> $DIR/empty-match.rs:52:20
110+
--> $DIR/empty-match.rs:55:20
84111
|
85112
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
86113
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@@ -98,7 +125,7 @@ LL | Bar,
98125
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
99126

100127
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
101-
--> $DIR/empty-match.rs:53:20
128+
--> $DIR/empty-match.rs:56:20
102129
|
103130
LL | match_no_arms!(NonEmptyEnum5::V1);
104131
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -122,7 +149,7 @@ LL | V5,
122149
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
123150

124151
error[E0004]: non-exhaustive patterns: `_` not covered
125-
--> $DIR/empty-match.rs:55:24
152+
--> $DIR/empty-match.rs:58:24
126153
|
127154
LL | match_guarded_arm!(0u8);
128155
| ^^^ pattern `_` not covered
@@ -135,8 +162,50 @@ LL ~ _ if false => {},
135162
LL + _ => todo!()
136163
|
137164

165+
error[E0004]: non-exhaustive patterns: `_` not covered
166+
--> $DIR/empty-match.rs:59:24
167+
|
168+
LL | match_guarded_arm!(0i8);
169+
| ^^^ pattern `_` not covered
170+
|
171+
= note: the matched value is of type `i8`
172+
= note: match arms with guards don't count towards exhaustivity
173+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
174+
|
175+
LL ~ _ if false => {},
176+
LL + _ => todo!()
177+
|
178+
179+
error[E0004]: non-exhaustive patterns: `_` not covered
180+
--> $DIR/empty-match.rs:60:24
181+
|
182+
LL | match_guarded_arm!(0usize);
183+
| ^^^^^^ pattern `_` not covered
184+
|
185+
= note: the matched value is of type `usize`
186+
= note: match arms with guards don't count towards exhaustivity
187+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
188+
|
189+
LL ~ _ if false => {},
190+
LL + _ => todo!()
191+
|
192+
193+
error[E0004]: non-exhaustive patterns: `_` not covered
194+
--> $DIR/empty-match.rs:61:24
195+
|
196+
LL | match_guarded_arm!(0isize);
197+
| ^^^^^^ pattern `_` not covered
198+
|
199+
= note: the matched value is of type `isize`
200+
= note: match arms with guards don't count towards exhaustivity
201+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
202+
|
203+
LL ~ _ if false => {},
204+
LL + _ => todo!()
205+
|
206+
138207
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
139-
--> $DIR/empty-match.rs:56:24
208+
--> $DIR/empty-match.rs:62:24
140209
|
141210
LL | match_guarded_arm!(NonEmptyStruct1);
142211
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@@ -155,7 +224,7 @@ LL + NonEmptyStruct1 => todo!()
155224
|
156225

157226
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
158-
--> $DIR/empty-match.rs:57:24
227+
--> $DIR/empty-match.rs:63:24
159228
|
160229
LL | match_guarded_arm!(NonEmptyStruct2(true));
161230
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@@ -174,7 +243,7 @@ LL + NonEmptyStruct2(_) => todo!()
174243
|
175244

176245
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
177-
--> $DIR/empty-match.rs:58:24
246+
--> $DIR/empty-match.rs:64:24
178247
|
179248
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
180249
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@@ -193,7 +262,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
193262
|
194263

195264
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
196-
--> $DIR/empty-match.rs:59:24
265+
--> $DIR/empty-match.rs:65:24
197266
|
198267
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
199268
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@@ -212,7 +281,7 @@ LL + NonEmptyUnion2 { .. } => todo!()
212281
|
213282

214283
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
215-
--> $DIR/empty-match.rs:60:24
284+
--> $DIR/empty-match.rs:66:24
216285
|
217286
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
218287
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
@@ -233,7 +302,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
233302
|
234303

235304
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
236-
--> $DIR/empty-match.rs:61:24
305+
--> $DIR/empty-match.rs:67:24
237306
|
238307
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
239308
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
@@ -256,7 +325,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
256325
|
257326

258327
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
259-
--> $DIR/empty-match.rs:62:24
328+
--> $DIR/empty-match.rs:68:24
260329
|
261330
LL | match_guarded_arm!(NonEmptyEnum5::V1);
262331
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -284,6 +353,6 @@ LL ~ _ if false => {},
284353
LL + _ => todo!()
285354
|
286355

287-
error: aborting due to 16 previous errors
356+
error: aborting due to 22 previous errors
288357

289358
For more information about this error, try `rustc --explain E0004`.

0 commit comments

Comments
 (0)