rust/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
850 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 {
_ => {} //~ ERROR unreachable pattern
2019-11-30 15:51:26 +00:00
}
}
fn main() {
match NonExhaustiveEnum::Unit {}
//~^ ERROR `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered [E0004]
2019-11-30 15:51:26 +00:00
match NormalEnum::Unit {}
//~^ ERROR `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered [E0004]
2019-11-30 15:51:26 +00:00
}