Skip to content

Commit 36d36a3

Browse files
committed
interpret: the MIR is actually at lifetime 'tcx
1 parent cdc509f commit 36d36a3

13 files changed

Lines changed: 75 additions & 74 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
9090
_destination:&interpret::MPlaceTy<'tcx,Self::Provenance>,
9191
_target:Option<BasicBlock>,
9292
_unwind:UnwindAction,
93-
) -> interpret::InterpResult<'tcx,Option<(&'mirBody<'tcx>, ty::Instance<'tcx>)>>{
93+
) -> interpret::InterpResult<'tcx,Option<(&'tcxBody<'tcx>, ty::Instance<'tcx>)>>{
9494
unimplemented!()
9595
}
9696

@@ -176,24 +176,24 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
176176

177177
fninit_frame_extra(
178178
_ecx:&mutInterpCx<'mir,'tcx,Self>,
179-
_frame: interpret::Frame<'mir,'tcx,Self::Provenance>,
179+
_frame: interpret::Frame<'tcx,Self::Provenance>,
180180
) -> interpret::InterpResult<
181181
'tcx,
182-
interpret::Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>,
182+
interpret::Frame<'tcx,Self::Provenance,Self::FrameExtra>,
183183
>{
184184
unimplemented!()
185185
}
186186

187187
fnstack<'a>(
188188
_ecx:&'aInterpCx<'mir,'tcx,Self>,
189-
) -> &'a[interpret::Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>]{
189+
) -> &'a[interpret::Frame<'tcx,Self::Provenance,Self::FrameExtra>]{
190190
// Return an empty stack instead of panicking, as `cur_span` uses it to evaluate constants.
191191
&[]
192192
}
193193

194194
fnstack_mut<'a>(
195195
_ecx:&'amutInterpCx<'mir,'tcx,Self>,
196-
) -> &'amutVec<interpret::Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>>{
196+
) -> &'amutVec<interpret::Frame<'tcx,Self::Provenance,Self::FrameExtra>>{
197197
unimplemented!()
198198
}
199199
}

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

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

61-
pubfnget_span_and_frames<'tcx,'mir>(
61+
pubfnget_span_and_frames<'tcx>(
6262
tcx:TyCtxtAt<'tcx>,
63-
stack:&[Frame<'mir,'tcx,implProvenance,implSized>],
64-
) -> (Span,Vec<errors::FrameNote>)
65-
where
66-
'tcx:'mir,
67-
{
63+
stack:&[Frame<'tcx,implProvenance,implSized>],
64+
) -> (Span,Vec<errors::FrameNote>){
6865
letmut 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)fnlint<'tcx,'mir,L>(
161+
pub(super)fnlint<'tcx,L>(
165162
tcx:TyCtxtAt<'tcx>,
166-
machine:&CompileTimeInterpreter<'mir,'tcx>,
163+
machine:&CompileTimeInterpreter<'tcx>,
167164
lint:&'static rustc_session::lint::Lint,
168165
decorator:implFnOnce(Vec<errors::FrameNote>) -> L,
169166
)where

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::CTRL_C_RECEIVED;
3434
fneval_body_using_ecx<'mir,'tcx,R:InterpretationResult<'tcx>>(
3535
ecx:&mutCompileTimeEvalContext<'mir,'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;
@@ -328,14 +328,14 @@ pub trait InterpretationResult<'tcx> {
328328
/// evaluation query.
329329
fnmake_result<'mir>(
330330
mplace:MPlaceTy<'tcx>,
331-
ecx:&mutInterpCx<'mir,'tcx,CompileTimeInterpreter<'mir,'tcx>>,
331+
ecx:&mutInterpCx<'mir,'tcx,CompileTimeInterpreter<'tcx>>,
332332
) -> Self;
333333
}
334334

335335
impl<'tcx>InterpretationResult<'tcx>forConstAlloc<'tcx>{
336336
fnmake_result<'mir>(
337337
mplace:MPlaceTy<'tcx>,
338-
_ecx:&mutInterpCx<'mir,'tcx,CompileTimeInterpreter<'mir,'tcx>>,
338+
_ecx:&mutInterpCx<'mir,'tcx,CompileTimeInterpreter<'tcx>>,
339339
) -> Self{
340340
ConstAlloc{alloc_id: mplace.ptr().provenance.unwrap().alloc_id(),ty: mplace.layout.ty}
341341
}
@@ -417,7 +417,7 @@ fn eval_in_interpreter<'tcx, R: InterpretationResult<'tcx>>(
417417

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

448448
#[inline(always)]
449449
fnreport_validation_error<'mir,'tcx>(
450-
ecx:&InterpCx<'mir,'tcx,CompileTimeInterpreter<'mir,'tcx>>,
450+
ecx:&InterpCx<'mir,'tcx,CompileTimeInterpreter<'tcx>>,
451451
error:InterpErrorInfo<'tcx>,
452452
alloc_id:AllocId,
453453
) -> ErrorHandled{

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ const TINY_LINT_TERMINATOR_LIMIT: usize = 20;
4545
constPROGRESS_INDICATOR_START:usize = 4_000_000;
4646

4747
/// Extra machine state for CTFE, and the Machine instance
48-
pubstructCompileTimeInterpreter<'mir,'tcx>{
48+
pubstructCompileTimeInterpreter<'tcx>{
4949
/// The number of terminators that have been evaluated.
5050
///
5151
/// This is used to produce lints informing the user that the compiler is not stuck.
5252
/// Set to `usize::MAX` to never report anything.
5353
pub(super)num_evaluated_steps:usize,
5454

5555
/// The virtual call stack.
56-
pub(super)stack:Vec<Frame<'mir,'tcx>>,
56+
pub(super)stack:Vec<Frame<'tcx>>,
5757

5858
/// Pattern matching on consts with references would be unsound if those references
5959
/// could point to anything mutable. Therefore, when evaluating consts and when constructing valtrees,
@@ -90,7 +90,7 @@ impl From<bool> for CanAccessMutGlobal {
9090
}
9191
}
9292

93-
impl<'mir,'tcx>CompileTimeInterpreter<'mir,'tcx>{
93+
impl<'tcx>CompileTimeInterpreter<'tcx>{
9494
pub(crate)fnnew(
9595
can_access_mut_global:CanAccessMutGlobal,
9696
check_alignment:CheckAlignment,
@@ -165,7 +165,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
165165
}
166166

167167
pub(crate)typeCompileTimeEvalContext<'mir,'tcx> =
168-
InterpCx<'mir,'tcx,CompileTimeInterpreter<'mir,'tcx>>;
168+
InterpCx<'mir,'tcx,CompileTimeInterpreter<'tcx>>;
169169

170170
#[derive(Debug,PartialEq,Eq,Copy,Clone)]
171171
pubenumMemoryKind{
@@ -371,7 +371,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
371371
}
372372
}
373373

374-
impl<'mir,'tcx> interpret::Machine<'mir,'tcx>forCompileTimeInterpreter<'mir,'tcx>{
374+
impl<'mir,'tcx:'mir> interpret::Machine<'mir,'tcx>forCompileTimeInterpreter<'tcx>{
375375
compile_time_machine!(<'mir,'tcx>);
376376

377377
typeMemoryKind = MemoryKind;
@@ -417,7 +417,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
417417
dest:&MPlaceTy<'tcx>,
418418
ret:Option<mir::BasicBlock>,
419419
_unwind: mir::UnwindAction,// unwinding is not supported in consts
420-
) -> InterpResult<'tcx,Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>>{
420+
) -> InterpResult<'tcx,Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>>{
421421
debug!("find_mir_or_eval_fn: {:?}", orig_instance);
422422

423423
// Replace some functions.
@@ -658,8 +658,8 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
658658
#[inline(always)]
659659
fninit_frame_extra(
660660
ecx:&mutInterpCx<'mir,'tcx,Self>,
661-
frame:Frame<'mir,'tcx>,
662-
) -> InterpResult<'tcx,Frame<'mir,'tcx>>{
661+
frame:Frame<'tcx>,
662+
) -> InterpResult<'tcx,Frame<'tcx>>{
663663
// Enforce stack size limit. Add 1 because this is run before the new frame is pushed.
664664
if !ecx.recursion_limit.value_within_limit(ecx.stack().len() + 1){
665665
throw_exhaust!(StackFrameLimitReached)
@@ -671,14 +671,14 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
671671
#[inline(always)]
672672
fnstack<'a>(
673673
ecx:&'aInterpCx<'mir,'tcx,Self>,
674-
) -> &'a[Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>]{
674+
) -> &'a[Frame<'tcx,Self::Provenance,Self::FrameExtra>]{
675675
&ecx.machine.stack
676676
}
677677

678678
#[inline(always)]
679679
fnstack_mut<'a>(
680680
ecx:&'amutInterpCx<'mir,'tcx,Self>,
681-
) -> &'amutVec<Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>>{
681+
) -> &'amutVec<Frame<'tcx,Self::Provenance,Self::FrameExtra>>{
682682
&mut ecx.machine.stack
683683
}
684684

‎compiler/rustc_const_eval/src/interpret/eval_context.rs‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ impl Drop for SpanGuard {
9090
}
9191

9292
/// A stack frame.
93-
pubstructFrame<'mir,'tcx,Prov:Provenance = CtfeProvenance,Extra = ()>{
93+
pubstructFrame<'tcx,Prov:Provenance = CtfeProvenance,Extra = ()>{
9494
////////////////////////////////////////////////////////////////////////////////
9595
// Function and callsite information
9696
////////////////////////////////////////////////////////////////////////////////
9797
/// The MIR for the function called on this frame.
98-
pubbody:&'mir mir::Body<'tcx>,
98+
pubbody:&'tcx mir::Body<'tcx>,
9999

100100
/// The def_id and args of the current function.
101101
pubinstance: ty::Instance<'tcx>,
@@ -232,8 +232,8 @@ impl<'tcx, Prov: Provenance> LocalState<'tcx, Prov> {
232232
}
233233
}
234234

235-
impl<'mir,'tcx,Prov:Provenance>Frame<'mir,'tcx,Prov>{
236-
pubfnwith_extra<Extra>(self,extra:Extra) -> Frame<'mir,'tcx,Prov,Extra>{
235+
impl<'tcx,Prov:Provenance>Frame<'tcx,Prov>{
236+
pubfnwith_extra<Extra>(self,extra:Extra) -> Frame<'tcx,Prov,Extra>{
237237
Frame{
238238
body:self.body,
239239
instance:self.instance,
@@ -247,7 +247,7 @@ impl<'mir, 'tcx, Prov: Provenance> Frame<'mir, 'tcx, Prov> {
247247
}
248248
}
249249

250-
impl<'mir,'tcx,Prov:Provenance,Extra>Frame<'mir,'tcx,Prov,Extra>{
250+
impl<'tcx,Prov:Provenance,Extra>Frame<'tcx,Prov,Extra>{
251251
/// Get the current location within the Frame.
252252
///
253253
/// If this is `Left`, we are not currently executing any particular statement in
@@ -517,14 +517,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
517517
}
518518

519519
#[inline(always)]
520-
pub(crate)fnstack(&self) -> &[Frame<'mir,'tcx,M::Provenance,M::FrameExtra>]{
520+
pub(crate)fnstack(&self) -> &[Frame<'tcx,M::Provenance,M::FrameExtra>]{
521521
M::stack(self)
522522
}
523523

524524
#[inline(always)]
525-
pub(crate)fnstack_mut(
526-
&mutself,
527-
) -> &mutVec<Frame<'mir,'tcx,M::Provenance,M::FrameExtra>>{
525+
pub(crate)fnstack_mut(&mutself) -> &mutVec<Frame<'tcx,M::Provenance,M::FrameExtra>>{
528526
M::stack_mut(self)
529527
}
530528

@@ -536,12 +534,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
536534
}
537535

538536
#[inline(always)]
539-
pubfnframe(&self) -> &Frame<'mir,'tcx,M::Provenance,M::FrameExtra>{
537+
pubfnframe(&self) -> &Frame<'tcx,M::Provenance,M::FrameExtra>{
540538
self.stack().last().expect("no call frames exist")
541539
}
542540

543541
#[inline(always)]
544-
pubfnframe_mut(&mutself) -> &mutFrame<'mir,'tcx,M::Provenance,M::FrameExtra>{
542+
pubfnframe_mut(&mutself) -> &mutFrame<'tcx,M::Provenance,M::FrameExtra>{
545543
self.stack_mut().last_mut().expect("no call frames exist")
546544
}
547545

@@ -602,7 +600,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
602600
T:TypeFoldable<TyCtxt<'tcx>>,
603601
>(
604602
&self,
605-
frame:&Frame<'mir,'tcx,M::Provenance,M::FrameExtra>,
603+
frame:&Frame<'tcx,M::Provenance,M::FrameExtra>,
606604
value:T,
607605
) -> Result<T,ErrorHandled>{
608606
frame
@@ -680,7 +678,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
680678
#[inline(always)]
681679
pub(super)fnlayout_of_local(
682680
&self,
683-
frame:&Frame<'mir,'tcx,M::Provenance,M::FrameExtra>,
681+
frame:&Frame<'tcx,M::Provenance,M::FrameExtra>,
684682
local: mir::Local,
685683
layout:Option<TyAndLayout<'tcx>>,
686684
) -> InterpResult<'tcx,TyAndLayout<'tcx>>{
@@ -803,7 +801,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
803801
pubfnpush_stack_frame(
804802
&mutself,
805803
instance: ty::Instance<'tcx>,
806-
body:&'mir mir::Body<'tcx>,
804+
body:&'tcx mir::Body<'tcx>,
807805
return_place:&MPlaceTy<'tcx,M::Provenance>,
808806
return_to_block:StackPopCleanup,
809807
) -> InterpResult<'tcx>{

‎compiler/rustc_const_eval/src/interpret/intern.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub trait HasStaticRootDefId {
4646
fnstatic_def_id(&self) -> Option<LocalDefId>;
4747
}
4848

49-
implHasStaticRootDefIdfor const_eval::CompileTimeInterpreter<'_,'_>{
49+
implHasStaticRootDefIdfor const_eval::CompileTimeInterpreter<'_>{
5050
fnstatic_def_id(&self) -> Option<LocalDefId>{
5151
Some(self.static_root_ids?.1)
5252
}

‎compiler/rustc_const_eval/src/interpret/machine.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
200200
destination:&MPlaceTy<'tcx,Self::Provenance>,
201201
target:Option<mir::BasicBlock>,
202202
unwind: mir::UnwindAction,
203-
) -> InterpResult<'tcx,Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>>;
203+
) -> InterpResult<'tcx,Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>>;
204204

205205
/// Execute `fn_val`. It is the hook's responsibility to advance the instruction
206206
/// pointer as appropriate.
@@ -478,18 +478,18 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
478478
/// Called immediately before a new stack frame gets pushed.
479479
fninit_frame_extra(
480480
ecx:&mutInterpCx<'mir,'tcx,Self>,
481-
frame:Frame<'mir,'tcx,Self::Provenance>,
482-
) -> InterpResult<'tcx,Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>>;
481+
frame:Frame<'tcx,Self::Provenance>,
482+
) -> InterpResult<'tcx,Frame<'tcx,Self::Provenance,Self::FrameExtra>>;
483483

484484
/// Borrow the current thread's stack.
485485
fnstack<'a>(
486486
ecx:&'aInterpCx<'mir,'tcx,Self>,
487-
) -> &'a[Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>];
487+
) -> &'a[Frame<'tcx,Self::Provenance,Self::FrameExtra>];
488488

489489
/// Mutably borrow the current thread's stack.
490490
fnstack_mut<'a>(
491491
ecx:&'amutInterpCx<'mir,'tcx,Self>,
492-
) -> &'amutVec<Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>>;
492+
) -> &'amutVec<Frame<'tcx,Self::Provenance,Self::FrameExtra>>;
493493

494494
/// Called immediately after a stack frame got pushed and its locals got initialized.
495495
fnafter_stack_push(_ecx:&mutInterpCx<'mir,'tcx,Self>) -> InterpResult<'tcx>{
@@ -499,7 +499,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
499499
/// Called just before the return value is copied to the caller-provided return place.
500500
fnbefore_stack_pop(
501501
_ecx:&InterpCx<'mir,'tcx,Self>,
502-
_frame:&Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>,
502+
_frame:&Frame<'tcx,Self::Provenance,Self::FrameExtra>,
503503
) -> InterpResult<'tcx>{
504504
Ok(())
505505
}
@@ -509,7 +509,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
509509
#[inline(always)]
510510
fnafter_stack_pop(
511511
_ecx:&mutInterpCx<'mir,'tcx,Self>,
512-
_frame:Frame<'mir,'tcx,Self::Provenance,Self::FrameExtra>,
512+
_frame:Frame<'tcx,Self::Provenance,Self::FrameExtra>,
513513
unwinding:bool,
514514
) -> InterpResult<'tcx,StackPopJump>{
515515
// By default, we do not support unwinding from panics

‎compiler/rustc_const_eval/src/interpret/util.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ where
8484
impl<'tcx>InterpretationResult<'tcx>for mir::interpret::ConstAllocation<'tcx>{
8585
fnmake_result<'mir>(
8686
mplace:MPlaceTy<'tcx>,
87-
ecx:&mutInterpCx<'mir,'tcx,CompileTimeInterpreter<'mir,'tcx>>,
87+
ecx:&mutInterpCx<'mir,'tcx,CompileTimeInterpreter<'tcx>>,
8888
) -> Self{
8989
let alloc_id = mplace.ptr().provenance.unwrap().alloc_id();
9090
let alloc = ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1;

‎src/tools/miri/src/borrow_tracker/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
354354

355355
fnon_stack_pop(
356356
&self,
357-
frame:&Frame<'mir,'tcx,Provenance,FrameExtra<'tcx>>,
357+
frame:&Frame<'tcx,Provenance,FrameExtra<'tcx>>,
358358
) -> InterpResult<'tcx>{
359359
let this = self.eval_context_ref();
360360
let borrow_tracker = this.machine.borrow_tracker.as_ref().unwrap();

0 commit comments

Comments
 (0)