@@ -164,8 +164,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
164
164
}
165
165
}
166
166
167
- pub ( crate ) type CompileTimeEvalContext < ' mir , ' tcx > =
168
- InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' tcx > > ;
167
+ pub ( crate ) type CompileTimeEvalContext < ' tcx > = InterpCx < ' tcx , CompileTimeInterpreter < ' tcx > > ;
169
168
170
169
#[ derive( Debug , PartialEq , Eq , Copy , Clone ) ]
171
170
pub enum MemoryKind {
@@ -197,7 +196,7 @@ impl interpret::MayLeak for ! {
197
196
}
198
197
}
199
198
200
- impl < ' mir , ' tcx : ' mir > CompileTimeEvalContext < ' mir , ' tcx > {
199
+ impl < ' tcx > CompileTimeEvalContext < ' tcx > {
201
200
fn location_triple_for_span ( & self , span : Span ) -> ( Symbol , u32 , u32 ) {
202
201
let topmost = span. ctxt ( ) . outer_expn ( ) . expansion_cause ( ) . unwrap_or ( span) ;
203
202
let caller = self . tcx . sess . source_map ( ) . lookup_char_pos ( topmost. lo ( ) ) ;
@@ -371,25 +370,25 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
371
370
}
372
371
}
373
372
374
- impl < ' mir , ' tcx : ' mir > interpret:: Machine < ' mir , ' tcx > for CompileTimeInterpreter < ' tcx > {
375
- compile_time_machine ! ( <' mir , ' tcx>) ;
373
+ impl < ' tcx > interpret:: Machine < ' tcx > for CompileTimeInterpreter < ' tcx > {
374
+ compile_time_machine ! ( <' tcx>) ;
376
375
377
376
type MemoryKind = MemoryKind ;
378
377
379
378
const PANIC_ON_ALLOC_FAIL : bool = false ; // will be raised as a proper error
380
379
381
380
#[ inline( always) ]
382
- fn enforce_alignment ( ecx : & InterpCx < ' mir , ' tcx , Self > ) -> bool {
381
+ fn enforce_alignment ( ecx : & InterpCx < ' tcx , Self > ) -> bool {
383
382
matches ! ( ecx. machine. check_alignment, CheckAlignment :: Error )
384
383
}
385
384
386
385
#[ inline( always) ]
387
- fn enforce_validity ( ecx : & InterpCx < ' mir , ' tcx , Self > , layout : TyAndLayout < ' tcx > ) -> bool {
386
+ fn enforce_validity ( ecx : & InterpCx < ' tcx , Self > , layout : TyAndLayout < ' tcx > ) -> bool {
388
387
ecx. tcx . sess . opts . unstable_opts . extra_const_ub_checks || layout. abi . is_uninhabited ( )
389
388
}
390
389
391
390
fn load_mir (
392
- ecx : & InterpCx < ' mir , ' tcx , Self > ,
391
+ ecx : & InterpCx < ' tcx , Self > ,
393
392
instance : ty:: InstanceDef < ' tcx > ,
394
393
) -> InterpResult < ' tcx , & ' tcx mir:: Body < ' tcx > > {
395
394
match instance {
@@ -410,7 +409,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
410
409
}
411
410
412
411
fn find_mir_or_eval_fn (
413
- ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
412
+ ecx : & mut InterpCx < ' tcx , Self > ,
414
413
orig_instance : ty:: Instance < ' tcx > ,
415
414
_abi : CallAbi ,
416
415
args : & [ FnArg < ' tcx > ] ,
@@ -448,15 +447,15 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
448
447
Ok ( Some ( ( ecx. load_mir ( instance. def , None ) ?, orig_instance) ) )
449
448
}
450
449
451
- fn panic_nounwind ( ecx : & mut InterpCx < ' mir , ' tcx , Self > , msg : & str ) -> InterpResult < ' tcx > {
450
+ fn panic_nounwind ( ecx : & mut InterpCx < ' tcx , Self > , msg : & str ) -> InterpResult < ' tcx > {
452
451
let msg = Symbol :: intern ( msg) ;
453
452
let span = ecx. find_closest_untracked_caller_location ( ) ;
454
453
let ( file, line, col) = ecx. location_triple_for_span ( span) ;
455
454
Err ( ConstEvalErrKind :: Panic { msg, file, line, col } . into ( ) )
456
455
}
457
456
458
457
fn call_intrinsic (
459
- ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
458
+ ecx : & mut InterpCx < ' tcx , Self > ,
460
459
instance : ty:: Instance < ' tcx > ,
461
460
args : & [ OpTy < ' tcx > ] ,
462
461
dest : & MPlaceTy < ' tcx , Self :: Provenance > ,
@@ -555,7 +554,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
555
554
}
556
555
557
556
fn assert_panic (
558
- ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
557
+ ecx : & mut InterpCx < ' tcx , Self > ,
559
558
msg : & AssertMessage < ' tcx > ,
560
559
_unwind : mir:: UnwindAction ,
561
560
) -> InterpResult < ' tcx > {
@@ -586,15 +585,15 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
586
585
}
587
586
588
587
fn binary_ptr_op (
589
- _ecx : & InterpCx < ' mir , ' tcx , Self > ,
588
+ _ecx : & InterpCx < ' tcx , Self > ,
590
589
_bin_op : mir:: BinOp ,
591
590
_left : & ImmTy < ' tcx > ,
592
591
_right : & ImmTy < ' tcx > ,
593
592
) -> InterpResult < ' tcx , ImmTy < ' tcx > > {
594
593
throw_unsup_format ! ( "pointer arithmetic or comparison is not supported at compile-time" ) ;
595
594
}
596
595
597
- fn increment_const_eval_counter ( ecx : & mut InterpCx < ' mir , ' tcx , Self > ) -> InterpResult < ' tcx > {
596
+ fn increment_const_eval_counter ( ecx : & mut InterpCx < ' tcx , Self > ) -> InterpResult < ' tcx > {
598
597
// The step limit has already been hit in a previous call to `increment_const_eval_counter`.
599
598
600
599
if let Some ( new_steps) = ecx. machine . num_evaluated_steps . checked_add ( 1 ) {
@@ -650,14 +649,14 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
650
649
}
651
650
652
651
#[ inline( always) ]
653
- fn expose_ptr ( _ecx : & mut InterpCx < ' mir , ' tcx , Self > , _ptr : Pointer ) -> InterpResult < ' tcx > {
652
+ fn expose_ptr ( _ecx : & mut InterpCx < ' tcx , Self > , _ptr : Pointer ) -> InterpResult < ' tcx > {
654
653
// This is only reachable with -Zunleash-the-miri-inside-of-you.
655
654
throw_unsup_format ! ( "exposing pointers is not possible at compile-time" )
656
655
}
657
656
658
657
#[ inline( always) ]
659
658
fn init_frame_extra (
660
- ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
659
+ ecx : & mut InterpCx < ' tcx , Self > ,
661
660
frame : Frame < ' tcx > ,
662
661
) -> InterpResult < ' tcx , Frame < ' tcx > > {
663
662
// Enforce stack size limit. Add 1 because this is run before the new frame is pushed.
@@ -670,14 +669,14 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
670
669
671
670
#[ inline( always) ]
672
671
fn stack < ' a > (
673
- ecx : & ' a InterpCx < ' mir , ' tcx , Self > ,
672
+ ecx : & ' a InterpCx < ' tcx , Self > ,
674
673
) -> & ' a [ Frame < ' tcx , Self :: Provenance , Self :: FrameExtra > ] {
675
674
& ecx. machine . stack
676
675
}
677
676
678
677
#[ inline( always) ]
679
678
fn stack_mut < ' a > (
680
- ecx : & ' a mut InterpCx < ' mir , ' tcx , Self > ,
679
+ ecx : & ' a mut InterpCx < ' tcx , Self > ,
681
680
) -> & ' a mut Vec < Frame < ' tcx , Self :: Provenance , Self :: FrameExtra > > {
682
681
& mut ecx. machine . stack
683
682
}
@@ -715,7 +714,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
715
714
}
716
715
717
716
fn retag_ptr_value (
718
- ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
717
+ ecx : & mut InterpCx < ' tcx , Self > ,
719
718
_kind : mir:: RetagKind ,
720
719
val : & ImmTy < ' tcx , CtfeProvenance > ,
721
720
) -> InterpResult < ' tcx , ImmTy < ' tcx , CtfeProvenance > > {
@@ -756,10 +755,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
756
755
Ok ( ( ) )
757
756
}
758
757
759
- fn before_alloc_read (
760
- ecx : & InterpCx < ' mir , ' tcx , Self > ,
761
- alloc_id : AllocId ,
762
- ) -> InterpResult < ' tcx > {
758
+ fn before_alloc_read ( ecx : & InterpCx < ' tcx , Self > , alloc_id : AllocId ) -> InterpResult < ' tcx > {
763
759
// Check if this is the currently evaluated static.
764
760
if Some ( alloc_id) == ecx. machine . static_root_ids . map ( |( id, _) | id) {
765
761
return Err ( ConstEvalErrKind :: RecursiveStatic . into ( ) ) ;
0 commit comments