@@ -6,7 +6,7 @@ use crate::interpret::{
6
6
} ;
7
7
use rustc_middle:: mir;
8
8
use rustc_middle:: mir:: interpret:: { EvalToValTreeResult , GlobalId } ;
9
- use rustc_middle:: ty:: { self , TyCtxt } ;
9
+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
10
10
use rustc_span:: { source_map:: DUMMY_SP , symbol:: Symbol } ;
11
11
12
12
mod error;
@@ -89,14 +89,15 @@ pub(crate) fn eval_to_valtree<'tcx>(
89
89
#[ instrument( skip( tcx) , level = "debug" ) ]
90
90
pub ( crate ) fn try_destructure_mir_constant < ' tcx > (
91
91
tcx : TyCtxt < ' tcx > ,
92
- param_env : ty :: ParamEnv < ' tcx > ,
93
- val : mir :: ConstantKind < ' tcx > ,
92
+ val : ConstValue < ' tcx > ,
93
+ ty : Ty < ' tcx > ,
94
94
) -> InterpResult < ' tcx , mir:: DestructuredConstant < ' tcx > > {
95
+ let param_env = ty:: ParamEnv :: reveal_all ( ) ;
95
96
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 ) ?;
97
98
98
99
// 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 ( ) {
100
101
ty:: Array ( _, len) => ( len. eval_target_usize ( tcx, param_env) as usize , None , op) ,
101
102
ty:: Adt ( def, _) if def. variants ( ) . is_empty ( ) => {
102
103
throw_ub ! ( Unreachable )
0 commit comments