]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/slice-pattern-const-3.rs
Rollup merge of #80298 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez
[rust.git] / src / test / ui / pattern / usefulness / slice-pattern-const-3.rs
1 #![deny(unreachable_patterns)]
2
3 fn main() {
4     let s = &["0x00"; 4][..]; //Slice of any value
5     const MAGIC_TEST: &[&str] = &["4", "5", "6", "7"]; //Const slice to pattern match with
6     match s {
7         MAGIC_TEST => (),
8         ["0x00", "0x00", "0x00", "0x00"] => (),
9         ["4", "5", "6", "7"] => (), //~ ERROR unreachable pattern
10         _ => (),
11     }
12     match s {
13         ["0x00", "0x00", "0x00", "0x00"] => (),
14         MAGIC_TEST => (),
15         ["4", "5", "6", "7"] => (), //~ ERROR unreachable pattern
16         _ => (),
17     }
18     match s {
19         ["0x00", "0x00", "0x00", "0x00"] => (),
20         ["4", "5", "6", "7"] => (),
21         MAGIC_TEST => (), //~ ERROR unreachable pattern
22         _ => (),
23     }
24     const FOO: [&str; 1] = ["boo"];
25     match ["baa"] {
26         ["0x00"] => (),
27         ["boo"] => (),
28         FOO => (), //~ ERROR unreachable pattern
29         _ => (),
30     }
31 }