]> git.lizzy.rs Git - rust.git/blob - src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
slice_patterns: remove gates in tests
[rust.git] / src / test / ui / or-patterns / exhaustiveness-unreachable-pattern.rs
1 #![feature(or_patterns)]
2
3 #![allow(incomplete_features)]
4 #![deny(unreachable_patterns)]
5
6 // We wrap patterns in a tuple because top-level or-patterns are special-cased for now.
7 fn main() {
8     // Get the fatal error out of the way
9     match (0u8,) {
10         (0 | _,) => {}
11         //~^ ERROR or-patterns are not fully implemented yet
12     }
13
14     match (0u8,) {
15         (1 | 2,) => {}
16         (1,) => {} //~ ERROR unreachable pattern
17         _ => {}
18     }
19     match (0u8,) {
20         (1 | 2,) => {}
21         (2,) => {} //~ ERROR unreachable pattern
22         _ => {}
23     }
24     match (0u8,) {
25         (1,) => {}
26         (2,) => {}
27         (1 | 2,) => {} //~ ERROR unreachable pattern
28         _ => {}
29     }
30     match (0u8, 0u8) {
31         (1 | 2, 3 | 4) => {}
32         (1, 3) => {} //~ ERROR unreachable pattern
33         (1, 4) => {} //~ ERROR unreachable pattern
34         (2, 4) => {} //~ ERROR unreachable pattern
35         (2 | 1, 4) => {} //~ ERROR unreachable pattern
36         (1, 5 | 6) => {}
37         (1, 4 | 5) => {} //~ ERROR unreachable pattern
38         _ => {}
39     }
40     match (Some(0u8),) {
41         (None | Some(1 | 2),) => {}
42         (Some(1),) => {} //~ ERROR unreachable pattern
43         (None,) => {} //~ ERROR unreachable pattern
44         _ => {}
45     }
46     match ((0u8,),) {
47         ((1 | 2,) | (3 | 4,),) => {},
48         ((1..=4,),) => {}, //~ ERROR unreachable pattern
49         _ => {},
50     }
51
52     match (0,) {
53         (1
54          | 1,) => {} //~ ERROR unreachable
55         _ => {}
56     }
57     match [0; 2] {
58         [0
59             | 0 //~ ERROR unreachable
60         , 0
61             | 0] => {} //~ ERROR unreachable
62         _ => {}
63     }
64     match &[][..] {
65         [0] => {}
66         [0, _] => {}
67         [0, _, _] => {}
68         [1, ..] => {}
69         [1 //~ ERROR unreachable
70             | 2, ..] => {}
71         _ => {}
72     }
73     match Some(0) {
74         Some(0) => {}
75         Some(0 //~ ERROR unreachable
76              | 1) => {}
77         _ => {}
78     }
79 }