interpret: get rid of 'mir lifetime everywhere · rust-lang/rust@e8379c9
@@ -164,8 +164,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
164164}
165165}
166166167-pub(crate) type CompileTimeEvalContext<'mir, 'tcx> =
168-InterpCx<'mir, 'tcx, CompileTimeInterpreter<'tcx>>;
167+pub(crate) type CompileTimeEvalContext<'tcx> = InterpCx<'tcx, CompileTimeInterpreter<'tcx>>;
169168170169#[derive(Debug, PartialEq, Eq, Copy, Clone)]
171170pub enum MemoryKind {
@@ -197,7 +196,7 @@ impl interpret::MayLeak for ! {
197196}
198197}
199198200-impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
199+impl<'tcx> CompileTimeEvalContext<'tcx> {
201200fn location_triple_for_span(&self, span: Span) -> (Symbol, u32, u32) {
202201let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
203202let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
@@ -371,25 +370,25 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
371370}
372371}
373372374-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>);
376375377376type MemoryKind = MemoryKind;
378377379378const PANIC_ON_ALLOC_FAIL: bool = false; // will be raised as a proper error
380379381380#[inline(always)]
382-fn enforce_alignment(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
381+fn enforce_alignment(ecx: &InterpCx<'tcx, Self>) -> bool {
383382matches!(ecx.machine.check_alignment, CheckAlignment::Error)
384383}
385384386385#[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 {
388387 ecx.tcx.sess.opts.unstable_opts.extra_const_ub_checks || layout.abi.is_uninhabited()
389388}
390389391390fn load_mir(
392-ecx: &InterpCx<'mir, 'tcx, Self>,
391+ecx: &InterpCx<'tcx, Self>,
393392instance: ty::InstanceDef<'tcx>,
394393) -> InterpResult<'tcx, &'tcx mir::Body<'tcx>> {
395394match instance {
@@ -410,7 +409,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
410409}
411410412411fn find_mir_or_eval_fn(
413-ecx: &mut InterpCx<'mir, 'tcx, Self>,
412+ecx: &mut InterpCx<'tcx, Self>,
414413orig_instance: ty::Instance<'tcx>,
415414_abi: CallAbi,
416415args: &[FnArg<'tcx>],
@@ -448,15 +447,15 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
448447Ok(Some((ecx.load_mir(instance.def, None)?, orig_instance)))
449448}
450449451-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> {
452451let msg = Symbol::intern(msg);
453452let span = ecx.find_closest_untracked_caller_location();
454453let (file, line, col) = ecx.location_triple_for_span(span);
455454Err(ConstEvalErrKind::Panic { msg, file, line, col }.into())
456455}
457456458457fn call_intrinsic(
459-ecx: &mut InterpCx<'mir, 'tcx, Self>,
458+ecx: &mut InterpCx<'tcx, Self>,
460459instance: ty::Instance<'tcx>,
461460args: &[OpTy<'tcx>],
462461dest: &MPlaceTy<'tcx, Self::Provenance>,
@@ -555,7 +554,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
555554}
556555557556fn assert_panic(
558-ecx: &mut InterpCx<'mir, 'tcx, Self>,
557+ecx: &mut InterpCx<'tcx, Self>,
559558msg: &AssertMessage<'tcx>,
560559_unwind: mir::UnwindAction,
561560) -> InterpResult<'tcx> {
@@ -586,15 +585,15 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
586585}
587586588587fn binary_ptr_op(
589-_ecx: &InterpCx<'mir, 'tcx, Self>,
588+_ecx: &InterpCx<'tcx, Self>,
590589_bin_op: mir::BinOp,
591590_left: &ImmTy<'tcx>,
592591_right: &ImmTy<'tcx>,
593592) -> InterpResult<'tcx, ImmTy<'tcx>> {
594593throw_unsup_format!("pointer arithmetic or comparison is not supported at compile-time");
595594}
596595597-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> {
598597// The step limit has already been hit in a previous call to `increment_const_eval_counter`.
599598600599if 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
650649}
651650652651#[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> {
654653// This is only reachable with -Zunleash-the-miri-inside-of-you.
655654throw_unsup_format!("exposing pointers is not possible at compile-time")
656655}
657656658657#[inline(always)]
659658fn init_frame_extra(
660-ecx: &mut InterpCx<'mir, 'tcx, Self>,
659+ecx: &mut InterpCx<'tcx, Self>,
661660frame: Frame<'tcx>,
662661) -> InterpResult<'tcx, Frame<'tcx>> {
663662// 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
670669671670#[inline(always)]
672671fn stack<'a>(
673-ecx: &'a InterpCx<'mir, 'tcx, Self>,
672+ecx: &'a InterpCx<'tcx, Self>,
674673) -> &'a [Frame<'tcx, Self::Provenance, Self::FrameExtra>] {
675674&ecx.machine.stack
676675}
677676678677#[inline(always)]
679678fn stack_mut<'a>(
680-ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
679+ecx: &'a mut InterpCx<'tcx, Self>,
681680) -> &'a mut Vec<Frame<'tcx, Self::Provenance, Self::FrameExtra>> {
682681&mut ecx.machine.stack
683682}
@@ -715,7 +714,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
715714}
716715717716fn retag_ptr_value(
718-ecx: &mut InterpCx<'mir, 'tcx, Self>,
717+ecx: &mut InterpCx<'tcx, Self>,
719718_kind: mir::RetagKind,
720719val: &ImmTy<'tcx, CtfeProvenance>,
721720) -> InterpResult<'tcx, ImmTy<'tcx, CtfeProvenance>> {
@@ -756,10 +755,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter
756755Ok(())
757756}
758757759-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> {
763759// Check if this is the currently evaluated static.
764760if Some(alloc_id) == ecx.machine.static_root_ids.map(|(id, _)| id) {
765761return Err(ConstEvalErrKind::RecursiveStatic.into());