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-13 23:18:55 +00:00
|
|
|
_ => {} //~ ERROR unreachable pattern
|
2019-11-30 15:51:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match NonExhaustiveEnum::Unit {}
|
2022-09-03 03:01:35 +00:00
|
|
|
//~^ ERROR `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered [E0004]
|
2019-11-30 15:51:26 +00:00
|
|
|
match NormalEnum::Unit {}
|
2022-09-03 03:01:35 +00:00
|
|
|
//~^ ERROR `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered [E0004]
|
2019-11-30 15:51:26 +00:00
|
|
|
}
|