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