Skip to content

Commit c00ecfa

Browse files
committed
Add some tests
1 parent 143fb43 commit c00ecfa

File tree

2 files changed

+49
-23
lines changed

2 files changed

+49
-23
lines changed

src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ fn main() {
55
let s1: &[bool; 1] = &[false; 1];
66
let s2: &[bool; 2] = &[false; 2];
77
let s3: &[bool; 3] = &[false; 3];
8+
let s10: &[bool; 10] = &[false; 10];
9+
10+
match s2 {
11+
//~^ ERROR `&[false, _]` not covered
12+
[true, .., true] => {}
13+
}
14+
match s3 {
15+
//~^ ERROR `&[false, _, _]` not covered
16+
[true, .., true] => {}
17+
}
18+
match s10 {
19+
//~^ ERROR `&[false, _, _, _, _, _, _, _, _, _]` not covered
20+
[true, .., true] => {}
21+
}
822

923
match s1 {
1024
[true, ..] => {}
@@ -27,10 +41,6 @@ fn main() {
2741
[.., false] => {}
2842
}
2943

30-
match s3 {
31-
//~^ ERROR `&[false, _, _]` not covered
32-
[true, .., true] => {}
33-
}
3444
match s {
3545
//~^ ERROR `&[_, ..]` not covered
3646
[] => {}
Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,107 @@
1+
error[E0004]: non-exhaustive patterns: `&[false, _]` not covered
2+
--> $DIR/slice-patterns-exhaustiveness.rs:10:11
3+
|
4+
LL | match s2 {
5+
| ^^ pattern `&[false, _]` not covered
6+
|
7+
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
8+
9+
error[E0004]: non-exhaustive patterns: `&[false, _, _]` not covered
10+
--> $DIR/slice-patterns-exhaustiveness.rs:14:11
11+
|
12+
LL | match s3 {
13+
| ^^ pattern `&[false, _, _]` not covered
14+
|
15+
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
16+
17+
error[E0004]: non-exhaustive patterns: `&[false, _, _, _, _, _, _, _, _, _]` not covered
18+
--> $DIR/slice-patterns-exhaustiveness.rs:18:11
19+
|
20+
LL | match s10 {
21+
| ^^^ pattern `&[false, _, _, _, _, _, _, _, _, _]` not covered
22+
|
23+
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
24+
125
error[E0004]: non-exhaustive patterns: `&[false, true]` not covered
2-
--> $DIR/slice-patterns-exhaustiveness.rs:13:11
26+
--> $DIR/slice-patterns-exhaustiveness.rs:27:11
327
|
428
LL | match s2 {
529
| ^^ pattern `&[false, true]` not covered
630
|
731
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
832

933
error[E0004]: non-exhaustive patterns: `&[false, _, true]` not covered
10-
--> $DIR/slice-patterns-exhaustiveness.rs:18:11
34+
--> $DIR/slice-patterns-exhaustiveness.rs:32:11
1135
|
1236
LL | match s3 {
1337
| ^^ pattern `&[false, _, true]` not covered
1438
|
1539
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
1640

1741
error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
18-
--> $DIR/slice-patterns-exhaustiveness.rs:23:11
42+
--> $DIR/slice-patterns-exhaustiveness.rs:37:11
1943
|
2044
LL | match s {
2145
| ^ pattern `&[false, .., true]` not covered
2246
|
2347
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
2448

25-
error[E0004]: non-exhaustive patterns: `&[false, _, _]` not covered
26-
--> $DIR/slice-patterns-exhaustiveness.rs:30:11
27-
|
28-
LL | match s3 {
29-
| ^^ pattern `&[false, _, _]` not covered
30-
|
31-
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
32-
3349
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
34-
--> $DIR/slice-patterns-exhaustiveness.rs:34:11
50+
--> $DIR/slice-patterns-exhaustiveness.rs:44:11
3551
|
3652
LL | match s {
3753
| ^ pattern `&[_, ..]` not covered
3854
|
3955
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
4056

4157
error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
42-
--> $DIR/slice-patterns-exhaustiveness.rs:38:11
58+
--> $DIR/slice-patterns-exhaustiveness.rs:48:11
4359
|
4460
LL | match s {
4561
| ^ pattern `&[_, _, ..]` not covered
4662
|
4763
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
4864

4965
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
50-
--> $DIR/slice-patterns-exhaustiveness.rs:43:11
66+
--> $DIR/slice-patterns-exhaustiveness.rs:53:11
5167
|
5268
LL | match s {
5369
| ^ pattern `&[false, ..]` not covered
5470
|
5571
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
5672

5773
error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered
58-
--> $DIR/slice-patterns-exhaustiveness.rs:48:11
74+
--> $DIR/slice-patterns-exhaustiveness.rs:58:11
5975
|
6076
LL | match s {
6177
| ^ pattern `&[false, _, ..]` not covered
6278
|
6379
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
6480

6581
error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered
66-
--> $DIR/slice-patterns-exhaustiveness.rs:54:11
82+
--> $DIR/slice-patterns-exhaustiveness.rs:64:11
6783
|
6884
LL | match s {
6985
| ^ pattern `&[_, .., false]` not covered
7086
|
7187
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
7288

7389
error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered
74-
--> $DIR/slice-patterns-exhaustiveness.rs:61:11
90+
--> $DIR/slice-patterns-exhaustiveness.rs:71:11
7591
|
7692
LL | match s {
7793
| ^ pattern `&[_, _, .., true]` not covered
7894
|
7995
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
8096

8197
error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered
82-
--> $DIR/slice-patterns-exhaustiveness.rs:68:11
98+
--> $DIR/slice-patterns-exhaustiveness.rs:78:11
8399
|
84100
LL | match s {
85101
| ^ pattern `&[true, _, .., _]` not covered
86102
|
87103
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
88104

89-
error: aborting due to 11 previous errors
105+
error: aborting due to 13 previous errors
90106

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

0 commit comments

Comments
 (0)