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