Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

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/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

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

+16-16
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ use crate::CTRL_C_RECEIVED;
3131

3232
// Returns a pointer to where the result lives
3333
#[instrument(level = "trace", skip(ecx, body))]
34-
fn eval_body_using_ecx<'mir, 'tcx, R: InterpretationResult<'tcx>>(
35-
ecx: &mut CompileTimeEvalContext<'mir, 'tcx>,
34+
fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
35+
ecx: &mut CompileTimeEvalContext<'tcx>,
3636
cid: GlobalId<'tcx>,
37-
body: &'mir mir::Body<'tcx>,
37+
body: &'tcx mir::Body<'tcx>,
3838
) -> InterpResult<'tcx, R> {
3939
trace!(?ecx.param_env);
4040
let tcx = *ecx.tcx;
@@ -134,12 +134,12 @@ fn eval_body_using_ecx<'mir, 'tcx, R: InterpretationResult<'tcx>>(
134134
/// that inform us about the generic bounds of the constant. E.g., using an associated constant
135135
/// of a function's generic parameter will require knowledge about the bounds on the generic
136136
/// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument.
137-
pub(crate) fn mk_eval_cx_to_read_const_val<'mir, 'tcx>(
137+
pub(crate) fn mk_eval_cx_to_read_const_val<'tcx>(
138138
tcx: TyCtxt<'tcx>,
139139
root_span: Span,
140140
param_env: ty::ParamEnv<'tcx>,
141141
can_access_mut_global: CanAccessMutGlobal,
142-
) -> CompileTimeEvalContext<'mir, 'tcx> {
142+
) -> CompileTimeEvalContext<'tcx> {
143143
debug!("mk_eval_cx: {:?}", param_env);
144144
InterpCx::new(
145145
tcx,
@@ -151,12 +151,12 @@ pub(crate) fn mk_eval_cx_to_read_const_val<'mir, 'tcx>(
151151

152152
/// Create an interpreter context to inspect the given `ConstValue`.
153153
/// Returns both the context and an `OpTy` that represents the constant.
154-
pub fn mk_eval_cx_for_const_val<'mir, 'tcx>(
154+
pub fn mk_eval_cx_for_const_val<'tcx>(
155155
tcx: TyCtxtAt<'tcx>,
156156
param_env: ty::ParamEnv<'tcx>,
157157
val: mir::ConstValue<'tcx>,
158158
ty: Ty<'tcx>,
159-
) -> Option<(CompileTimeEvalContext<'mir, 'tcx>, OpTy<'tcx>)> {
159+
) -> Option<(CompileTimeEvalContext<'tcx>, OpTy<'tcx>)> {
160160
let ecx = mk_eval_cx_to_read_const_val(tcx.tcx, tcx.span, param_env, CanAccessMutGlobal::No);
161161
let op = ecx.const_val_to_op(val, ty, None).ok()?;
162162
Some((ecx, op))
@@ -170,7 +170,7 @@ pub fn mk_eval_cx_for_const_val<'mir, 'tcx>(
170170
/// encounter an `Indirect` they cannot handle.
171171
#[instrument(skip(ecx), level = "debug")]
172172
pub(super) fn op_to_const<'tcx>(
173-
ecx: &CompileTimeEvalContext<'_, 'tcx>,
173+
ecx: &CompileTimeEvalContext<'tcx>,
174174
op: &OpTy<'tcx>,
175175
for_diagnostics: bool,
176176
) -> ConstValue<'tcx> {
@@ -326,16 +326,16 @@ pub trait InterpretationResult<'tcx> {
326326
/// This function takes the place where the result of the evaluation is stored
327327
/// and prepares it for returning it in the appropriate format needed by the specific
328328
/// evaluation query.
329-
fn make_result<'mir>(
329+
fn make_result(
330330
mplace: MPlaceTy<'tcx>,
331-
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
331+
ecx: &mut InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
332332
) -> Self;
333333
}
334334

335335
impl<'tcx> InterpretationResult<'tcx> for ConstAlloc<'tcx> {
336-
fn make_result<'mir>(
336+
fn make_result(
337337
mplace: MPlaceTy<'tcx>,
338-
_ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
338+
_ecx: &mut InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
339339
) -> Self {
340340
ConstAlloc { alloc_id: mplace.ptr().provenance.unwrap().alloc_id(), ty: mplace.layout.ty }
341341
}
@@ -416,8 +416,8 @@ fn eval_in_interpreter<'tcx, R: InterpretationResult<'tcx>>(
416416
}
417417

418418
#[inline(always)]
419-
fn const_validate_mplace<'mir, 'tcx>(
420-
ecx: &InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
419+
fn const_validate_mplace<'tcx>(
420+
ecx: &InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
421421
mplace: &MPlaceTy<'tcx>,
422422
cid: GlobalId<'tcx>,
423423
) -> Result<(), ErrorHandled> {
@@ -446,8 +446,8 @@ fn const_validate_mplace<'mir, 'tcx>(
446446
}
447447

448448
#[inline(always)]
449-
fn report_validation_error<'mir, 'tcx>(
450-
ecx: &InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
449+
fn report_validation_error<'tcx>(
450+
ecx: &InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
451451
error: InterpErrorInfo<'tcx>,
452452
alloc_id: AllocId,
453453
) -> ErrorHandled {
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.