Files
rust/src/test/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs

38 lines
758 B
Rust
Raw Normal View History

2019-11-30 15:51:26 +00:00
#![deny(unreachable_patterns)]
#[non_exhaustive]
pub enum NonExhaustiveEnum {
Unit,
2019-12-04 16:04:44 +00:00
//~^ not covered
2019-11-30 15:51:26 +00:00
Tuple(u32),
2019-12-04 16:04:44 +00:00
//~^ not covered
2019-11-30 15:51:26 +00:00
Struct { field: u32 }
2019-12-04 16:04:44 +00:00
//~^ not covered
2019-11-30 15:51:26 +00:00
}
pub enum NormalEnum {
Unit,
2019-12-04 16:04:44 +00:00
//~^ not covered
2019-11-30 15:51:26 +00:00
Tuple(u32),
2019-12-04 16:04:44 +00:00
//~^ not covered
2019-11-30 15:51:26 +00:00
Struct { field: u32 }
2019-12-04 16:04:44 +00:00
//~^ not covered
2019-11-30 15:51:26 +00:00
}
#[non_exhaustive]
pub enum EmptyNonExhaustiveEnum {}
fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) {
match x {}
match x {
2020-11-12 17:28:55 +00:00
_ => {}, //~ ERROR unreachable pattern
2019-11-30 15:51:26 +00:00
}
}
fn main() {
match NonExhaustiveEnum::Unit {}
2019-12-04 16:04:44 +00:00
//~^ ERROR `Unit`, `Tuple(_)` and `Struct { .. }` not covered [E0004]
2019-11-30 15:51:26 +00:00
match NormalEnum::Unit {}
2019-12-04 16:04:44 +00:00
//~^ ERROR `Unit`, `Tuple(_)` and `Struct { .. }` not covered [E0004]
2019-11-30 15:51:26 +00:00
}