]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs
parser will not give wrong help message for 'public'
[rust.git] / src / test / ui / rfc-2008-non-exhaustive / enum_same_crate_empty_match.rs
1 #![deny(unreachable_patterns)]
2
3 #[non_exhaustive]
4 pub enum NonExhaustiveEnum {
5     Unit,
6     //~^ not covered
7     Tuple(u32),
8     //~^ not covered
9     Struct { field: u32 }
10     //~^ not covered
11 }
12
13 pub enum NormalEnum {
14     Unit,
15     //~^ not covered
16     Tuple(u32),
17     //~^ not covered
18     Struct { field: u32 }
19     //~^ not covered
20 }
21
22 #[non_exhaustive]
23 pub enum EmptyNonExhaustiveEnum {}
24
25 fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) {
26     match x {}
27     match x {
28         _ => {} //~ ERROR unreachable pattern
29     }
30 }
31
32 fn main() {
33     match NonExhaustiveEnum::Unit {}
34     //~^ ERROR `Unit`, `Tuple(_)` and `Struct { .. }` not covered [E0004]
35     match NormalEnum::Unit {}
36     //~^ ERROR `Unit`, `Tuple(_)` and `Struct { .. }` not covered [E0004]
37 }