summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_const_eval/src/const_eval/valtrees.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_const_eval/src/const_eval/valtrees.rs')
-rw-r--r--compiler/rustc_const_eval/src/const_eval/valtrees.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs
index a73f778d4..4d54c0183 100644
--- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs
+++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs
@@ -8,7 +8,7 @@ use crate::interpret::{
use crate::interpret::{MPlaceTy, Value};
use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt};
use rustc_span::source_map::DUMMY_SP;
-use rustc_target::abi::{Align, VariantIdx};
+use rustc_target::abi::{Align, FieldIdx, VariantIdx, FIRST_VARIANT};
#[instrument(skip(ecx), level = "debug")]
fn branches<'tcx>(
@@ -412,7 +412,8 @@ fn valtree_into_mplace<'tcx>(
let inner_ty = match ty.kind() {
ty::Adt(def, substs) => {
- def.variant(VariantIdx::from_u32(0)).fields[i].ty(tcx, substs)
+ let i = FieldIdx::from_usize(i);
+ def.variant(FIRST_VARIANT).fields[i].ty(tcx, substs)
}
ty::Tuple(inner_tys) => inner_tys[i],
_ => bug!("unexpected unsized type {:?}", ty),