]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/or-patterns.rs
Add some more tests
[rust.git] / src / test / compile-fail / or-patterns.rs
1 // should-ice
2 #![allow(incomplete_features)]
3 #![feature(or_patterns)]
4 #![deny(unreachable_patterns)]
5
6 // The ice will get removed once or-patterns are correctly implemented
7 fn main() {
8     // We wrap patterns in a tuple because top-level or-patterns are special-cased for now.
9     match (0u8,) {
10         (1 | 2,) => {}
11         //~^ ERROR simplifyable pattern found
12         // This above is the ICE error message
13         _ => {}
14     }
15
16     match (0u8,) {
17         (1 | 2,) => {}
18         (1,) => {} //~ ERROR unreachable pattern
19         _ => {}
20     }
21     match (0u8,) {
22         (1 | 2,) => {}
23         (2,) => {} //~ ERROR unreachable pattern
24         _ => {}
25     }
26     match (0u8,) {
27         (1,) => {}
28         (2,) => {}
29         (1 | 2,) => {} //~ ERROR unreachable pattern
30         _ => {}
31     }
32     match (0u8,) {
33         (1 | 1,) => {} // redundancy not detected for now
34         _ => {}
35     }
36     match (0u8, 0u8) {
37         (1 | 2, 3 | 4) => {}
38         (1, 2) => {}
39         (1, 3) => {} //~ ERROR unreachable pattern
40         (1, 4) => {} //~ ERROR unreachable pattern
41         (2, 4) => {} //~ ERROR unreachable pattern
42         (2 | 1, 4) => {} //~ ERROR unreachable pattern
43         _ => {}
44     }
45     match (Some(0u8),) {
46         (None | Some(1 | 2),) => {}
47         (Some(1),) => {} //~ ERROR unreachable pattern
48         (None,) => {} //~ ERROR unreachable pattern
49         (Some(_),) => {}
50     }
51     match ((0u8,),) {
52         ((1 | 2,) | (3 | 4,),) => {},
53         ((1..=4,),) => {}, //~ ERROR unreachable pattern
54         ((_,),) => {},
55     }
56 }