Skip to content

Commit a59072e

Browse files
committedMay 27, 2024
Auto merge of #125602 - RalfJung:interpret-mir-lifetime, r=oli-obk
interpret: get rid of 'mir lifetime I realized our MIR bodies are actually at lifetime `'tcx`, so we don't need to carry around this other lifetime everywhere. r? `@oli-obk`
2 parents b582f80 + e8379c9 commit a59072e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+727
-815
lines changed
 

‎compiler/rustc_const_eval/src/const_eval/dummy_machine.rs

+19-21
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ impl HasStaticRootDefId for DummyMachine {
4444
}
4545
}
4646

47-
impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
48-
interpret::compile_time_machine!(<'mir, 'tcx>);
47+
impl<'tcx> interpret::Machine<'tcx> for DummyMachine {
48+
interpret::compile_time_machine!(<'tcx>);
4949
type MemoryKind = !;
5050
const PANIC_ON_ALLOC_FAIL: bool = true;
5151

5252
// We want to just eval random consts in the program, so `eval_mir_const` can fail.
5353
const ALL_CONSTS_ARE_PRECHECKED: bool = false;
5454

5555
#[inline(always)]
56-
fn enforce_alignment(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
56+
fn enforce_alignment(_ecx: &InterpCx<'tcx, Self>) -> bool {
5757
false // no reason to enforce alignment
5858
}
5959

60-
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>, _layout: TyAndLayout<'tcx>) -> bool {
60+
fn enforce_validity(_ecx: &InterpCx<'tcx, Self>, _layout: TyAndLayout<'tcx>) -> bool {
6161
false
6262
}
6363

@@ -83,26 +83,26 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
8383
}
8484

8585
fn find_mir_or_eval_fn(
86-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
86+
_ecx: &mut InterpCx<'tcx, Self>,
8787
_instance: ty::Instance<'tcx>,
8888
_abi: rustc_target::spec::abi::Abi,
8989
_args: &[interpret::FnArg<'tcx, Self::Provenance>],
9090
_destination: &interpret::MPlaceTy<'tcx, Self::Provenance>,
9191
_target: Option<BasicBlock>,
9292
_unwind: UnwindAction,
93-
) -> interpret::InterpResult<'tcx, Option<(&'mir Body<'tcx>, ty::Instance<'tcx>)>> {
93+
) -> interpret::InterpResult<'tcx, Option<(&'tcx Body<'tcx>, ty::Instance<'tcx>)>> {
9494
unimplemented!()
9595
}
9696

9797
fn panic_nounwind(
98-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
98+
_ecx: &mut InterpCx<'tcx, Self>,
9999
_msg: &str,
100100
) -> interpret::InterpResult<'tcx> {
101101
unimplemented!()
102102
}
103103

104104
fn call_intrinsic(
105-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
105+
_ecx: &mut InterpCx<'tcx, Self>,
106106
_instance: ty::Instance<'tcx>,
107107
_args: &[interpret::OpTy<'tcx, Self::Provenance>],
108108
_destination: &interpret::MPlaceTy<'tcx, Self::Provenance>,
@@ -113,15 +113,15 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
113113
}
114114

115115
fn assert_panic(
116-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
116+
_ecx: &mut InterpCx<'tcx, Self>,
117117
_msg: &rustc_middle::mir::AssertMessage<'tcx>,
118118
_unwind: UnwindAction,
119119
) -> interpret::InterpResult<'tcx> {
120120
unimplemented!()
121121
}
122122

123123
fn binary_ptr_op(
124-
ecx: &InterpCx<'mir, 'tcx, Self>,
124+
ecx: &InterpCx<'tcx, Self>,
125125
bin_op: BinOp,
126126
left: &interpret::ImmTy<'tcx, Self::Provenance>,
127127
right: &interpret::ImmTy<'tcx, Self::Provenance>,
@@ -168,32 +168,30 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
168168
}
169169

170170
fn expose_ptr(
171-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
171+
_ecx: &mut InterpCx<'tcx, Self>,
172172
_ptr: interpret::Pointer<Self::Provenance>,
173173
) -> interpret::InterpResult<'tcx> {
174174
unimplemented!()
175175
}
176176

177177
fn init_frame_extra(
178-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
179-
_frame: interpret::Frame<'mir, 'tcx, Self::Provenance>,
180-
) -> interpret::InterpResult<
181-
'tcx,
182-
interpret::Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
183-
> {
178+
_ecx: &mut InterpCx<'tcx, Self>,
179+
_frame: interpret::Frame<'tcx, Self::Provenance>,
180+
) -> interpret::InterpResult<'tcx, interpret::Frame<'tcx, Self::Provenance, Self::FrameExtra>>
181+
{
184182
unimplemented!()
185183
}
186184

187185
fn stack<'a>(
188-
_ecx: &'a InterpCx<'mir, 'tcx, Self>,
189-
) -> &'a [interpret::Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>] {
186+
_ecx: &'a InterpCx<'tcx, Self>,
187+
) -> &'a [interpret::Frame<'tcx, Self::Provenance, Self::FrameExtra>] {
190188
// Return an empty stack instead of panicking, as `cur_span` uses it to evaluate constants.
191189
&[]
192190
}
193191

194192
fn stack_mut<'a>(
195-
_ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
196-
) -> &'a mut Vec<interpret::Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>> {
193+
_ecx: &'a mut InterpCx<'tcx, Self>,
194+
) -> &'a mut Vec<interpret::Frame<'tcx, Self::Provenance, Self::FrameExtra>> {
197195
unimplemented!()
198196
}
199197
}

‎compiler/rustc_const_eval/src/const_eval/error.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
5858
}
5959
}
6060

61-
pub fn get_span_and_frames<'tcx, 'mir>(
61+
pub fn get_span_and_frames<'tcx>(
6262
tcx: TyCtxtAt<'tcx>,
63-
stack: &[Frame<'mir, 'tcx, impl Provenance, impl Sized>],
64-
) -> (Span, Vec<errors::FrameNote>)
65-
where
66-
'tcx: 'mir,
67-
{
63+
stack: &[Frame<'tcx, impl Provenance, impl Sized>],
64+
) -> (Span, Vec<errors::FrameNote>) {
6865
let mut stacktrace = Frame::generate_stacktrace_from_stack(stack);
6966
// Filter out `requires_caller_location` frames.
7067
stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*tcx));
@@ -161,9 +158,9 @@ where
161158

162159
/// Emit a lint from a const-eval situation.
163160
// Even if this is unused, please don't remove it -- chances are we will need to emit a lint during const-eval again in the future!
164-
pub(super) fn lint<'tcx, 'mir, L>(
161+
pub(super) fn lint<'tcx, L>(
165162
tcx: TyCtxtAt<'tcx>,
166-
machine: &CompileTimeInterpreter<'mir, 'tcx>,
163+
machine: &CompileTimeInterpreter<'tcx>,
167164
lint: &'static rustc_session::lint::Lint,
168165
decorator: impl FnOnce(Vec<errors::FrameNote>) -> L,
169166
) where

0 commit comments

Comments
 (0)
Please sign in to comment.