]> git.lizzy.rs Git - rust.git/blob - src/test/ui/uninhabited/uninhabited-patterns.rs
slice_patterns: remove gates in tests
[rust.git] / src / test / ui / uninhabited / uninhabited-patterns.rs
1 #![feature(box_patterns)]
2 #![feature(box_syntax)]
3 #![feature(never_type)]
4 #![feature(exhaustive_patterns)]
5
6 #![deny(unreachable_patterns)]
7
8 mod foo {
9     pub struct SecretlyEmpty {
10         _priv: !,
11     }
12 }
13
14 struct NotSoSecretlyEmpty {
15     _priv: !,
16 }
17
18 fn foo() -> Option<NotSoSecretlyEmpty> {
19     None
20 }
21
22 fn main() {
23     let x: &[!] = &[];
24
25     match x {
26         &[]   => (),
27         &[..] => (),    //~ ERROR unreachable pattern
28     };
29
30     let x: Result<Box<NotSoSecretlyEmpty>, &[Result<!, !>]> = Err(&[]);
31     match x {
32         Ok(box _) => (),    //~ ERROR unreachable pattern
33         Err(&[]) => (),
34         Err(&[..]) => (),   //~ ERROR unreachable pattern
35     }
36
37     let x: Result<foo::SecretlyEmpty, Result<NotSoSecretlyEmpty, u32>> = Err(Err(123));
38     match x {
39         Ok(_y) => (),
40         Err(Err(_y)) => (),
41         Err(Ok(_y)) => (),  //~ ERROR unreachable pattern
42     }
43
44     while let Some(_y) = foo() {
45         //~^ ERROR unreachable pattern
46     }
47 }