]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/slice-pattern-const.rs
Auto merge of #56160 - oli-obk:const_fn_let, r=nikomatsakis
[rust.git] / src / test / ui / pattern / slice-pattern-const.rs
1 #![deny(unreachable_patterns)]
2
3 fn main() {
4     let s = &[0x00; 4][..]; //Slice of any value
5     const MAGIC_TEST: &[u8] = b"TEST"; //Const slice to pattern match with
6     match s {
7         MAGIC_TEST => (),
8         [0x00, 0x00, 0x00, 0x00] => (),
9         [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
10         _ => (),
11     }
12     match s {
13         [0x00, 0x00, 0x00, 0x00] => (),
14         MAGIC_TEST => (),
15         [84, 69, 83, 84] => (), //~ ERROR unreachable pattern
16         _ => (),
17     }
18     match s {
19         [0x00, 0x00, 0x00, 0x00] => (),
20         [84, 69, 83, 84] => (),
21         MAGIC_TEST => (), //~ ERROR unreachable pattern
22         _ => (),
23     }
24     const FOO: [u8; 1] = [4];
25     match [99] {
26         [0x00] => (),
27         [4] => (),
28         FOO => (), //~ ERROR unreachable pattern
29         _ => (),
30     }
31     const BAR: &[u8; 1] = &[4];
32     match &[99] {
33         [0x00] => (),
34         [4] => (),
35         BAR => (), //~ ERROR unreachable pattern
36         b"a" => (),
37         _ => (),
38     }
39
40     const BOO: &[u8; 0] = &[];
41     match &[] {
42         [] => (),
43         BOO => (), //~ ERROR unreachable pattern
44         b"" => (), //~ ERROR unreachable pattern
45         _ => (), //~ ERROR unreachable pattern
46     }
47 }