@@ -97,7 +97,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(
97
97
pub ( super ) fn op_to_const < ' tcx > (
98
98
ecx : & CompileTimeEvalContext < ' _ , ' tcx > ,
99
99
op : OpTy < ' tcx > ,
100
- ) -> & ' tcx ty :: Const < ' tcx > {
100
+ ) -> ConstValue < ' tcx > {
101
101
// We do not have value optimizations for everything.
102
102
// Only scalars and slices, since they are very common.
103
103
// 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>(
144
144
ConstValue :: Scalar ( Scalar :: zst ( ) )
145
145
}
146
146
} ;
147
- let val = match immediate {
147
+ match immediate {
148
148
Ok ( mplace) => to_const_value ( mplace) ,
149
149
// see comment on `let try_as_immediate` above
150
150
Err ( ImmTy { imm : Immediate :: Scalar ( x) , .. } ) => match x {
@@ -166,8 +166,7 @@ pub(super) fn op_to_const<'tcx>(
166
166
let len: usize = len. try_into ( ) . unwrap ( ) ;
167
167
ConstValue :: Slice { data, start, end : start + len }
168
168
}
169
- } ;
170
- ecx. tcx . mk_const ( ty:: Const { val : ty:: ConstKind :: Value ( val) , ty : op. layout . ty } )
169
+ }
171
170
}
172
171
173
172
fn validate_and_turn_into_const < ' tcx > (
@@ -195,13 +194,10 @@ fn validate_and_turn_into_const<'tcx>(
195
194
// whether they become immediates.
196
195
if is_static || cid. promoted . is_some ( ) {
197
196
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
+ } )
205
201
} else {
206
202
Ok ( op_to_const ( & ecx, mplace. into ( ) ) )
207
203
}
0 commit comments