rust/tests/ui/rfcs/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 09:51:26 -06:00
#![deny(unreachable_patterns)]
#[non_exhaustive]
pub enum NonExhaustiveEnum {
Unit,
2019-12-04 10:04:44 -06:00
//~^ not covered
2019-11-30 09:51:26 -06:00
Tuple(u32),
2019-12-04 10:04:44 -06:00
//~^ not covered
2019-11-30 09:51:26 -06:00
Struct { field: u32 }
2019-12-04 10:04:44 -06:00
//~^ not covered
2019-11-30 09:51:26 -06:00
}
pub enum NormalEnum {
Unit,
2019-12-04 10:04:44 -06:00
//~^ not covered
2019-11-30 09:51:26 -06:00
Tuple(u32),
2019-12-04 10:04:44 -06:00
//~^ not covered
2019-11-30 09:51:26 -06:00
Struct { field: u32 }
2019-12-04 10:04:44 -06:00
//~^ not covered
2019-11-30 09:51:26 -06:00
}
#[non_exhaustive]
pub enum EmptyNonExhaustiveEnum {}
fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) {
match x {}
match x {
_ => {} //~ ERROR unreachable pattern
2019-11-30 09:51:26 -06:00
}
}
fn main() {
match NonExhaustiveEnum::Unit {}
//~^ ERROR `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered [E0004]
2019-11-30 09:51:26 -06:00
match NormalEnum::Unit {}
//~^ ERROR `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered [E0004]
2019-11-30 09:51:26 -06:00
}