@@ -18,9 +18,9 @@ use super::{CanAccessStatics, CompileTimeEvalContext, CompileTimeInterpreter};
1818use crate :: errors;
1919use crate :: interpret:: eval_nullary_intrinsic;
2020use crate :: interpret:: {
21- intern_const_alloc_recursive, Allocation , ConstAlloc , ConstValue , CtfeValidationMode , GlobalId ,
22- Immediate , InternKind , InterpCx , InterpError , InterpResult , MPlaceTy , MemoryKind , OpTy ,
23- RefTracking , StackPopCleanup ,
21+ intern_const_alloc_recursive, ConstAlloc , ConstValue , CtfeValidationMode , GlobalId , Immediate ,
22+ InternKind , InterpCx , InterpError , InterpResult , MPlaceTy , MemoryKind , OpTy , RefTracking ,
23+ StackPopCleanup ,
2424} ;
2525
2626// Returns a pointer to where the result lives
@@ -111,7 +111,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(
111111pub ( super ) fn op_to_const < ' tcx > (
112112 ecx : & CompileTimeEvalContext < ' _ , ' tcx > ,
113113 op : & OpTy < ' tcx > ,
114- ) -> ConstValue < ' tcx > {
114+ ) -> ConstValue {
115115 // We do not have value optimizations for everything.
116116 // Only scalars and slices, since they are very common.
117117 // Note that further down we turn scalars of uninitialized bits back to `ByRef`. These can result
@@ -170,21 +170,11 @@ pub(super) fn op_to_const<'tcx>(
170170 Immediate :: ScalarPair ( a, b) => {
171171 debug ! ( "ScalarPair(a: {:?}, b: {:?})" , a, b) ;
172172 // We know `offset` is relative to the allocation, so we can use `into_parts`.
173- let ( data, start) = match a. to_pointer ( ecx) . unwrap ( ) . into_parts ( ) {
174- ( Some ( alloc_id) , offset) => {
175- ( ecx. tcx . global_alloc ( alloc_id) . unwrap_memory ( ) , offset. bytes ( ) )
176- }
177- ( None , _offset) => (
178- ecx. tcx . mk_const_alloc ( Allocation :: from_bytes_byte_aligned_immutable (
179- b"" as & [ u8 ] ,
180- ) ) ,
181- 0 ,
182- ) ,
183- } ;
173+ let ( alloc_id, start) = a. to_pointer ( ecx) . unwrap ( ) . into_parts ( ) ;
184174 let len = b. to_target_usize ( ecx) . unwrap ( ) ;
185- let start = start. try_into ( ) . unwrap ( ) ;
175+ let start = start. bytes ( ) . try_into ( ) . unwrap ( ) ;
186176 let len: usize = len. try_into ( ) . unwrap ( ) ;
187- ConstValue :: Slice { data , start, end : start + len }
177+ ConstValue :: Slice { alloc_id , start, end : start + len }
188178 }
189179 Immediate :: Uninit => to_const_value ( & op. assert_mem_place ( ) ) ,
190180 } ,
@@ -196,7 +186,7 @@ pub(crate) fn turn_into_const_value<'tcx>(
196186 tcx : TyCtxt < ' tcx > ,
197187 constant : ConstAlloc < ' tcx > ,
198188 key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
199- ) -> ConstValue < ' tcx > {
189+ ) -> ConstValue {
200190 let cid = key. value ;
201191 let def_id = cid. instance . def . def_id ( ) ;
202192 let is_static = tcx. is_static ( def_id) ;
0 commit comments