Rollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakis
Permit uninhabited enums to cast into ints
This essentially reverts part of #6204; it is unclear why that [commit](c0f587de34
) was introduced, and I suspect no one remembers.
The changed code was only called from casting checks and appears to not affect any callers of that code (other than permitting this one case).
Fixes #75647.
This commit is contained in:
commit
496e2feed6
4 changed files with 12 additions and 12 deletions
|
@ -2436,8 +2436,10 @@ impl<'tcx> AdtDef {
|
|||
self.variants.iter().flat_map(|v| v.fields.iter())
|
||||
}
|
||||
|
||||
/// Whether the ADT lacks fields. Note that this includes uninhabited enums,
|
||||
/// e.g., `enum Void {}` is considered payload free as well.
|
||||
pub fn is_payloadfree(&self) -> bool {
|
||||
!self.variants.is_empty() && self.variants.iter().all(|v| v.fields.is_empty())
|
||||
self.variants.iter().all(|v| v.fields.is_empty())
|
||||
}
|
||||
|
||||
/// Return a `VariantDef` given a variant id.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue