|
1 |
| -//compile-pass |
| 1 | +#![deny(unreachable_patterns)] |
2 | 2 |
|
3 | 3 | fn main() {
|
4 | 4 | let s = &[0x00; 4][..]; //Slice of any value
|
5 | 5 | const MAGIC_TEST: &[u8] = b"TEST"; //Const slice to pattern match with
|
6 | 6 | match s {
|
7 | 7 | MAGIC_TEST => (),
|
8 | 8 | [0x00, 0x00, 0x00, 0x00] => (),
|
9 |
| - [84, 69, 83, 84] => (), // this should warn |
| 9 | + [84, 69, 83, 84] => (), //~ ERROR unreachable pattern |
10 | 10 | _ => (),
|
11 | 11 | }
|
12 | 12 | match s {
|
13 | 13 | [0x00, 0x00, 0x00, 0x00] => (),
|
14 | 14 | MAGIC_TEST => (),
|
15 |
| - [84, 69, 83, 84] => (), // this should warn |
| 15 | + [84, 69, 83, 84] => (), //~ ERROR unreachable pattern |
16 | 16 | _ => (),
|
17 | 17 | }
|
18 | 18 | match s {
|
19 | 19 | [0x00, 0x00, 0x00, 0x00] => (),
|
20 | 20 | [84, 69, 83, 84] => (),
|
21 |
| - MAGIC_TEST => (), // this should warn |
| 21 | + MAGIC_TEST => (), //~ ERROR unreachable pattern |
22 | 22 | _ => (),
|
23 | 23 | }
|
24 | 24 | const FOO: [u8; 1] = [4];
|
25 | 25 | match [99] {
|
26 | 26 | [0x00] => (),
|
27 | 27 | [4] => (),
|
28 |
| - FOO => (), // this should warn |
| 28 | + FOO => (), //~ ERROR unreachable pattern |
29 | 29 | _ => (),
|
30 | 30 | }
|
31 | 31 | const BAR: &[u8; 1] = &[4];
|
32 | 32 | match &[99] {
|
33 | 33 | [0x00] => (),
|
34 | 34 | [4] => (),
|
35 |
| - BAR => (), // this should warn |
| 35 | + BAR => (), //~ ERROR unreachable pattern |
36 | 36 | b"a" => (),
|
37 | 37 | _ => (),
|
38 | 38 | }
|
39 | 39 |
|
40 | 40 | const BOO: &[u8; 0] = &[];
|
41 | 41 | match &[] {
|
42 | 42 | [] => (),
|
43 |
| - BOO => (), // this should warn |
44 |
| - b"" => (), |
45 |
| - _ => (), |
| 43 | + BOO => (), //~ ERROR unreachable pattern |
| 44 | + b"" => (), //~ ERROR unreachable pattern |
| 45 | + _ => (), //~ ERROR unreachable pattern |
46 | 46 | }
|
47 | 47 | }
|
0 commit comments