-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
slice-patterns-exhaustiveness.rs
107 lines (101 loc) · 2.18 KB
/
slice-patterns-exhaustiveness.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#![feature(slice_patterns)]
fn main() {
let s: &[bool] = &[true; 0];
let s1: &[bool; 1] = &[false; 1];
let s2: &[bool; 2] = &[false; 2];
let s3: &[bool; 3] = &[false; 3];
let s10: &[bool; 10] = &[false; 10];
match s2 {
//~^ ERROR `&[false, _]` not covered
[true, .., true] => {}
}
match s3 {
//~^ ERROR `&[false, ..]` not covered
[true, .., true] => {}
}
match s10 {
//~^ ERROR `&[false, ..]` not covered
[true, .., true] => {}
}
match s1 {
[true, ..] => {}
[.., false] => {}
}
match s2 {
//~^ ERROR `&[false, true]` not covered
[true, ..] => {}
[.., false] => {}
}
match s3 {
//~^ ERROR `&[false, .., true]` not covered
[true, ..] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[false, .., true]` not covered
[] => {}
[true, ..] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[_, ..]` not covered
[] => {}
}
match s {
//~^ ERROR `&[_, _, ..]` not covered
[] => {}
[_] => {}
}
match s {
//~^ ERROR `&[false, ..]` not covered
[] => {}
[true, ..] => {}
}
match s {
//~^ ERROR `&[false, _, ..]` not covered
[] => {}
[_] => {}
[true, ..] => {}
}
match s {
//~^ ERROR `&[_, .., false]` not covered
[] => {}
[_] => {}
[.., true] => {}
}
match s {
//~^ ERROR `&[_, _, .., true]` not covered
[] => {}
[_] => {}
[_, _] => {}
[.., false] => {}
}
match s {
//~^ ERROR `&[true, _, .., _]` not covered
[] => {}
[_] => {}
[_, _] => {}
[false, .., false] => {}
}
const CONST: &[bool] = &[true];
match s {
//~^ ERROR `&[..]` not covered
CONST => {}
}
match s {
//~^ ERROR `&[true]` not covered
[] => {},
[false] => {},
CONST => {},
[_, _, ..] => {}
}
const CONST1: &[bool; 1] = &[true];
match s1 {
//~^ ERROR `&[false]` not covered
CONST1 => {}
}
match s1 {
CONST1 => {}
[false] => {}
}
}