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

38 lines
822 B
Rust
Raw Normal View History

2019-11-30 15:51:26 +00:00
#![deny(unreachable_patterns)]
#[non_exhaustive]
pub enum NonExhaustiveEnum {
Unit,
//~^ variant not covered
Tuple(u32),
//~^ variant not covered
Struct { field: u32 }
//~^ variant not covered
}
pub enum NormalEnum {
Unit,
//~^ variant not covered
Tuple(u32),
//~^ variant not covered
Struct { field: u32 }
//~^ variant not covered
}
#[non_exhaustive]
pub enum EmptyNonExhaustiveEnum {}
fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) {
match x {}
match x {
_ => {} // FIXME: should be unreachable
}
}
fn main() {
match NonExhaustiveEnum::Unit {}
//~^ ERROR multiple patterns of type `NonExhaustiveEnum` are not handled [E0004]
match NormalEnum::Unit {}
//~^ ERROR multiple patterns of type `NormalEnum` are not handled [E0004]
}