diff options
Diffstat (limited to 'compiler/rustc_const_eval/src/const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/mod.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index c49c5ecac26..6fd7f707e7e 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -105,13 +105,13 @@ fn const_to_valtree_inner<'tcx>( ty::Array(_, len) => branches(usize::try_from(len.eval_usize(ecx.tcx.tcx, ecx.param_env)).unwrap(), None), ty::Adt(def, _) => { - if def.variants.is_empty() { + if def.variants().is_empty() { bug!("uninhabited types should have errored and never gotten converted to valtree") } let variant = ecx.read_discriminant(&place.into()).unwrap().1; - branches(def.variants[variant].fields.len(), def.is_enum().then_some(variant)) + branches(def.variant(variant).fields.len(), def.is_enum().then_some(variant)) } ty::Never @@ -150,11 +150,11 @@ pub(crate) fn try_destructure_const<'tcx>( // Checks if we have any variants, to avoid downcasting to a non-existing variant (when // there are no variants `read_discriminant` successfully returns a non-existing variant // index). - ty::Adt(def, _) if def.variants.is_empty() => throw_ub!(Unreachable), + ty::Adt(def, _) if def.variants().is_empty() => throw_ub!(Unreachable), ty::Adt(def, _) => { let variant = ecx.read_discriminant(&op)?.1; let down = ecx.operand_downcast(&op, variant)?; - (def.variants[variant].fields.len(), Some(variant), down) + (def.variant(variant).fields.len(), Some(variant), down) } ty::Tuple(substs) => (substs.len(), None, op), _ => bug!("cannot destructure constant {:?}", val), |
