@@ -523,7 +523,6 @@ fn validate_and_turn_into_const<'a, 'tcx>(
523
523
constant : RawConst < ' tcx > ,
524
524
key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
525
525
) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
526
- let cid = key. value ;
527
526
let ecx = mk_eval_cx ( tcx, tcx. def_span ( key. value . instance . def_id ( ) ) , key. param_env ) ;
528
527
let val = ( || {
529
528
let op = ecx. raw_const_to_mplace ( constant) ?. into ( ) ;
@@ -539,9 +538,17 @@ fn validate_and_turn_into_const<'a, 'tcx>(
539
538
) ?;
540
539
}
541
540
// Now that we validated, turn this into a proper constant.
542
- let def_id = cid. instance . def . def_id ( ) ;
543
- let normalize = tcx. is_static ( def_id) . is_none ( ) && cid. promoted . is_none ( ) ;
544
- op_to_const ( & ecx, op, normalize)
541
+ let val = match op. layout . abi {
542
+ layout:: Abi :: Scalar ( ..) => ConstValue :: Scalar ( ecx. read_immediate ( op) ?. to_scalar ( ) ?) ,
543
+ layout:: Abi :: ScalarPair ( ..) if op. layout . ty . is_slice ( ) => {
544
+ let ( a, b) = ecx. read_immediate ( op) ?. to_scalar_pair ( ) ?;
545
+ ConstValue :: Slice ( a, b. to_usize ( & ecx) ?)
546
+ } ,
547
+ _ => ConstValue :: ByRef ,
548
+ } ;
549
+ let ptr = Pointer :: from ( constant. alloc_id ) ;
550
+ let alloc = constant. alloc ;
551
+ Ok ( ty:: Const { val, ty : op. layout . ty , alloc : Some ( ( alloc, ptr) ) } )
545
552
} ) ( ) ;
546
553
547
554
val. map_err ( |error| {
0 commit comments