11//! Propagates constants for early reporting of statically known
22//! assertion failures
33
4- use std:: borrow:: Cow ;
54use std:: cell:: Cell ;
65
76use rustc_ast:: ast:: Mutability ;
8- use rustc_data_structures:: fx:: FxHashMap ;
97use rustc_hir:: def:: DefKind ;
108use rustc_hir:: HirId ;
119use rustc_index:: bit_set:: BitSet ;
@@ -29,9 +27,9 @@ use rustc_trait_selection::traits;
2927
3028use crate :: const_eval:: error_to_const_error;
3129use 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 ,
3533} ;
3634use crate :: transform:: { MirPass , MirSource } ;
3735
@@ -162,27 +160,9 @@ impl<'mir, 'tcx> ConstPropMachine<'mir, 'tcx> {
162160}
163161
164162impl < ' 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>) ;
168164
169- type FrameExtra = ( ) ;
170165 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- }
186166
187167 fn find_mir_or_eval_fn (
188168 _ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
@@ -194,16 +174,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
194174 Ok ( None )
195175 }
196176
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-
207177 fn call_intrinsic (
208178 _ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
209179 _instance : ty:: Instance < ' tcx > ,
@@ -236,20 +206,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
236206 throw_machine_stop_str ! ( "pointer arithmetic or comparisons aren't supported in ConstProp" )
237207 }
238208
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-
253209 fn box_alloc (
254210 _ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
255211 _dest : PlaceTy < ' tcx > ,
@@ -290,14 +246,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
290246 Ok ( ( ) )
291247 }
292248
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-
301249 #[ inline( always) ]
302250 fn stack (
303251 ecx : & ' a InterpCx < ' mir , ' tcx , Self > ,
0 commit comments