diff options
Diffstat (limited to 'compiler/rustc_transmute/src')
| -rw-r--r-- | compiler/rustc_transmute/src/layout/tree.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 83463babc4f..049f4734e7b 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -339,14 +339,12 @@ pub(crate) mod rustc { match layout.variants() { Variants::Single { index } => { - // Hilariously, `Single` is used even for 0-variant enums; - // `index` is just junk in that case. - if ty.ty_adt_def().unwrap().variants().is_empty() { - Ok(Self::uninhabited()) - } else { + if let Some(index) = index { // `Variants::Single` on enums with variants denotes that // the enum delegates its layout to the variant at `index`. layout_of_variant(*index, None) + } else { + Ok(Self::uninhabited()) } } Variants::Multiple { tag, tag_encoding, tag_field, .. } => { @@ -504,7 +502,7 @@ pub(crate) mod rustc { ty::Adt(def, args) => { match layout.variants { Variants::Single { index } => { - let field = &def.variant(index).fields[i]; + let field = &def.variant(index.unwrap()).fields[i]; field.ty(cx.tcx(), args) } // Discriminant field for enums (where applicable). |
