1
1
//! Propagates constants for early reporting of statically known
2
2
//! assertion failures
3
3
4
- use std:: borrow:: Cow ;
5
4
use std:: cell:: Cell ;
6
5
7
6
use rustc_ast:: ast:: Mutability ;
8
- use rustc_data_structures:: fx:: FxHashMap ;
9
7
use rustc_hir:: def:: DefKind ;
10
8
use rustc_hir:: HirId ;
11
9
use rustc_index:: bit_set:: BitSet ;
@@ -29,9 +27,9 @@ use rustc_trait_selection::traits;
29
27
30
28
use crate :: const_eval:: error_to_const_error;
31
29
use crate :: interpret:: {
32
- self , intern_const_alloc_recursive, AllocId , Allocation , Frame , ImmTy , Immediate , InternKind ,
33
- InterpCx , LocalState , LocalValue , Memory , MemoryKind , OpTy , Operand as InterpOperand , PlaceTy ,
34
- Pointer , ScalarMaybeUndef , StackPopCleanup ,
30
+ self , compile_time_machine , intern_const_alloc_recursive, AllocId , Allocation , Frame , ImmTy ,
31
+ Immediate , InternKind , InterpCx , LocalState , LocalValue , Memory , MemoryKind , OpTy ,
32
+ Operand as InterpOperand , PlaceTy , Pointer , ScalarMaybeUndef , StackPopCleanup ,
35
33
} ;
36
34
use crate :: transform:: { MirPass , MirSource } ;
37
35
@@ -162,27 +160,9 @@ impl<'mir, 'tcx> ConstPropMachine<'mir, 'tcx> {
162
160
}
163
161
164
162
impl < ' mir , ' tcx > interpret:: Machine < ' mir , ' tcx > for ConstPropMachine < ' mir , ' tcx > {
165
- type MemoryKind = !;
166
- type PointerTag = ( ) ;
167
- type ExtraFnVal = !;
163
+ compile_time_machine ! ( <' mir, ' tcx>) ;
168
164
169
- type FrameExtra = ( ) ;
170
165
type MemoryExtra = ( ) ;
171
- type AllocExtra = ( ) ;
172
-
173
- type MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ;
174
-
175
- const GLOBAL_KIND : Option < !> = None ; // no copying of globals from `tcx` to machine memory
176
-
177
- #[ inline( always) ]
178
- fn enforce_alignment ( _memory_extra : & Self :: MemoryExtra ) -> bool {
179
- false
180
- }
181
-
182
- #[ inline( always) ]
183
- fn enforce_validity ( _ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool {
184
- false
185
- }
186
166
187
167
fn find_mir_or_eval_fn (
188
168
_ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
@@ -194,16 +174,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
194
174
Ok ( None )
195
175
}
196
176
197
- fn call_extra_fn (
198
- _ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
199
- fn_val : !,
200
- _args : & [ OpTy < ' tcx > ] ,
201
- _ret : Option < ( PlaceTy < ' tcx > , BasicBlock ) > ,
202
- _unwind : Option < BasicBlock > ,
203
- ) -> InterpResult < ' tcx > {
204
- match fn_val { }
205
- }
206
-
207
177
fn call_intrinsic (
208
178
_ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
209
179
_instance : ty:: Instance < ' tcx > ,
@@ -236,20 +206,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
236
206
throw_machine_stop_str ! ( "pointer arithmetic or comparisons aren't supported in ConstProp" )
237
207
}
238
208
239
- #[ inline( always) ]
240
- fn init_allocation_extra < ' b > (
241
- _memory_extra : & ( ) ,
242
- _id : AllocId ,
243
- alloc : Cow < ' b , Allocation > ,
244
- _kind : Option < MemoryKind < !> > ,
245
- ) -> ( Cow < ' b , Allocation < Self :: PointerTag > > , Self :: PointerTag ) {
246
- // We do not use a tag so we can just cheaply forward the allocation
247
- ( alloc, ( ) )
248
- }
249
-
250
- #[ inline( always) ]
251
- fn tag_global_base_pointer ( _memory_extra : & ( ) , _id : AllocId ) -> Self :: PointerTag { }
252
-
253
209
fn box_alloc (
254
210
_ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
255
211
_dest : PlaceTy < ' tcx > ,
@@ -290,14 +246,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
290
246
Ok ( ( ) )
291
247
}
292
248
293
- #[ inline( always) ]
294
- fn init_frame_extra (
295
- _ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
296
- frame : Frame < ' mir , ' tcx > ,
297
- ) -> InterpResult < ' tcx , Frame < ' mir , ' tcx > > {
298
- Ok ( frame)
299
- }
300
-
301
249
#[ inline( always) ]
302
250
fn stack (
303
251
ecx : & ' a InterpCx < ' mir , ' tcx , Self > ,
0 commit comments