@@ -97,7 +97,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(
9797pub ( super ) fn op_to_const < ' tcx > (
9898 ecx : & CompileTimeEvalContext < ' _ , ' tcx > ,
9999 op : OpTy < ' tcx > ,
100- ) -> & ' tcx ty :: Const < ' tcx > {
100+ ) -> ConstValue < ' tcx > {
101101 // We do not have value optimizations for everything.
102102 // Only scalars and slices, since they are very common.
103103 // Note that further down we turn scalars of undefined bits back to `ByRef`. These can result
@@ -144,7 +144,7 @@ pub(super) fn op_to_const<'tcx>(
144144 ConstValue :: Scalar ( Scalar :: zst ( ) )
145145 }
146146 } ;
147- let val = match immediate {
147+ match immediate {
148148 Ok ( mplace) => to_const_value ( mplace) ,
149149 // see comment on `let try_as_immediate` above
150150 Err ( ImmTy { imm : Immediate :: Scalar ( x) , .. } ) => match x {
@@ -166,8 +166,7 @@ pub(super) fn op_to_const<'tcx>(
166166 let len: usize = len. try_into ( ) . unwrap ( ) ;
167167 ConstValue :: Slice { data, start, end : start + len }
168168 }
169- } ;
170- ecx. tcx . mk_const ( ty:: Const { val : ty:: ConstKind :: Value ( val) , ty : op. layout . ty } )
169+ }
171170}
172171
173172fn validate_and_turn_into_const < ' tcx > (
@@ -195,13 +194,10 @@ fn validate_and_turn_into_const<'tcx>(
195194 // whether they become immediates.
196195 if is_static || cid. promoted . is_some ( ) {
197196 let ptr = mplace. ptr . assert_ptr ( ) ;
198- Ok ( tcx. mk_const ( ty:: Const {
199- val : ty:: ConstKind :: Value ( ConstValue :: ByRef {
200- alloc : ecx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
201- offset : ptr. offset ,
202- } ) ,
203- ty : mplace. layout . ty ,
204- } ) )
197+ Ok ( ConstValue :: ByRef {
198+ alloc : ecx. tcx . alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) ,
199+ offset : ptr. offset ,
200+ } )
205201 } else {
206202 Ok ( op_to_const ( & ecx, mplace. into ( ) ) )
207203 }
0 commit comments