@@ -6,7 +6,7 @@ use crate::interpret::{
66} ;
77use rustc_middle:: mir;
88use rustc_middle:: mir:: interpret:: { EvalToValTreeResult , GlobalId } ;
9- use rustc_middle:: ty:: { self , TyCtxt } ;
9+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
1010use rustc_span:: { source_map:: DUMMY_SP , symbol:: Symbol } ;
1111
1212mod error;
@@ -89,14 +89,15 @@ pub(crate) fn eval_to_valtree<'tcx>(
8989#[ instrument( skip( tcx) , level = "debug" ) ]
9090pub ( crate ) fn try_destructure_mir_constant < ' tcx > (
9191 tcx : TyCtxt < ' tcx > ,
92- param_env : ty :: ParamEnv < ' tcx > ,
93- val : mir :: ConstantKind < ' tcx > ,
92+ val : ConstValue < ' tcx > ,
93+ ty : Ty < ' tcx > ,
9494) -> InterpResult < ' tcx , mir:: DestructuredConstant < ' tcx > > {
95+ let param_env = ty:: ParamEnv :: reveal_all ( ) ;
9596 let ecx = mk_eval_cx ( tcx, DUMMY_SP , param_env, CanAccessStatics :: No ) ;
96- let op = ecx. eval_mir_constant ( & val, None , None ) ?;
97+ let op = ecx. const_val_to_op ( val, ty , None ) ?;
9798
9899 // We go to `usize` as we cannot allocate anything bigger anyway.
99- let ( field_count, variant, down) = match val . ty ( ) . kind ( ) {
100+ let ( field_count, variant, down) = match ty . kind ( ) {
100101 ty:: Array ( _, len) => ( len. eval_target_usize ( tcx, param_env) as usize , None , op) ,
101102 ty:: Adt ( def, _) if def. variants ( ) . is_empty ( ) => {
102103 throw_ub ! ( Unreachable )
0 commit comments