]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/match-byte-array-patterns.rs
7541ea3e2e2632988ec80e5def457bcc9a1cb7e7
[rust.git] / src / test / ui / pattern / usefulness / match-byte-array-patterns.rs
1 #![feature(slice_patterns)]
2 #![deny(unreachable_patterns)]
3
4 fn main() {
5     let buf = &[0, 1, 2, 3];
6
7     match buf {
8         b"AAAA" => {},
9         &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern
10         _ => {}
11     }
12
13     match buf {
14         &[0x41, 0x41, 0x41, 0x41] => {}
15         b"AAAA" => {}, //~ ERROR unreachable pattern
16         _ => {}
17     }
18
19     match buf {
20         &[_, 0x41, 0x41, 0x41] => {},
21         b"AAAA" => {}, //~ ERROR unreachable pattern
22         _ => {}
23     }
24
25     match buf {
26         &[0x41, .., 0x41] => {}
27         b"AAAA" => {}, //~ ERROR unreachable pattern
28         _ => {}
29     }
30
31     let buf: &[u8] = buf;
32
33     match buf {
34         b"AAAA" => {},
35         &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern
36         _ => {}
37     }
38
39     match buf {
40         &[0x41, 0x41, 0x41, 0x41] => {}
41         b"AAAA" => {}, //~ ERROR unreachable pattern
42         _ => {}
43     }
44
45     match buf {
46         &[_, 0x41, 0x41, 0x41] => {},
47         b"AAAA" => {}, //~ ERROR unreachable pattern
48         _ => {}
49     }
50
51     match buf {
52         &[0x41, .., 0x41] => {}
53         b"AAAA" => {}, //~ ERROR unreachable pattern
54         _ => {}
55     }
56 }