You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#60529 - davidtwco:rfc-2008-uninhabited, r=petrochenkov
RFC 2008: Uninhabitedness fixes for enum variants and tests
Part of rust-lang#44109.
At the request of @Centril, this PR adds tests asserting that uninhabited non-exhaustive types are considered inhabited in extern crates. In adding these tests, I fixed an oversight in the implementation of RFC 2008 on enum variants that resulted in non-exhaustive enum variants being considered uninhabited in extern crates.
Before this PR, these lines would error:
```rust
// extern crate
pub enum UninhabitedVariants {
#[non_exhaustive] Tuple(!),
#[non_exhaustive] Struct { x: ! }
}
pub enum PartiallyInhabitedVariants {
Tuple(u8),
#[non_exhaustive] Struct { x: ! }
}
// current crate
match uninhabited_variant() /* fn() -> Option<UninhabitedVariants> */ {
Some(_x) => (), //~ ERROR unreachable pattern
None => (),
}
while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inhabited_variant() /* fn() -> PartiallyInhabitedVariants */ {
//~^ ERROR unreachable pattern
}
```
cc @Centril
r? @petrochenkov
0 commit comments