Skip to content

Commit 2ba4af9

Browse files
committed
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 4d0a56e + d5d5b45 commit 2ba4af9

Some content is hidden

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

61 files changed

+458
-505
lines changed

src/alloc_addresses/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl GlobalStateInner {
8585
}
8686
}
8787

88-
pub fn remove_unreachable_allocs(&mut self, allocs: &LiveAllocs<'_, '_, '_>) {
88+
pub fn remove_unreachable_allocs(&mut self, allocs: &LiveAllocs<'_, '_>) {
8989
// `exposed` and `int_to_ptr_map` are cleared immediately when an allocation
9090
// is freed, so `base_addr` is the only one we have to clean up based on the GC.
9191
self.base_addr.retain(|id, _| allocs.is_live(*id));
@@ -101,8 +101,8 @@ fn align_addr(addr: u64, align: u64) -> u64 {
101101
}
102102
}
103103

104-
impl<'mir, 'tcx: 'mir> EvalContextExtPriv<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
105-
trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
104+
impl<'tcx> EvalContextExtPriv<'tcx> for crate::MiriInterpCx<'tcx> {}
105+
trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
106106
// Returns the exposed `AllocId` that corresponds to the specified addr,
107107
// or `None` if the addr is out of bounds
108108
fn alloc_id_from_addr(&self, addr: u64) -> Option<AllocId> {
@@ -234,8 +234,8 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
234234
}
235235
}
236236

237-
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
238-
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
237+
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
238+
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
239239
fn expose_ptr(&mut self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> {
240240
let ecx = self.eval_context_mut();
241241
let global_state = ecx.machine.alloc_addresses.get_mut();
@@ -341,7 +341,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
341341
}
342342
}
343343

344-
impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
344+
impl<'tcx> MiriMachine<'tcx> {
345345
pub fn free_alloc_id(&mut self, dead_id: AllocId, size: Size, align: Align, kind: MemoryKind) {
346346
let global_state = self.alloc_addresses.get_mut();
347347
let rng = self.rng.get_mut();

src/borrow_tracker/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl GlobalStateInner {
192192
id
193193
}
194194

195-
pub fn new_frame(&mut self, machine: &MiriMachine<'_, '_>) -> FrameState {
195+
pub fn new_frame(&mut self, machine: &MiriMachine<'_>) -> FrameState {
196196
let call_id = self.next_call_id;
197197
trace!("new_frame: Assigning call ID {}", call_id);
198198
if self.tracked_call_ids.contains(&call_id) {
@@ -213,7 +213,7 @@ impl GlobalStateInner {
213213
}
214214
}
215215

216-
pub fn root_ptr_tag(&mut self, id: AllocId, machine: &MiriMachine<'_, '_>) -> BorTag {
216+
pub fn root_ptr_tag(&mut self, id: AllocId, machine: &MiriMachine<'_>) -> BorTag {
217217
self.root_ptr_tags.get(&id).copied().unwrap_or_else(|| {
218218
let tag = self.new_ptr();
219219
if self.tracked_pointer_tags.contains(&tag) {
@@ -229,7 +229,7 @@ impl GlobalStateInner {
229229
})
230230
}
231231

232-
pub fn remove_unreachable_allocs(&mut self, allocs: &LiveAllocs<'_, '_, '_>) {
232+
pub fn remove_unreachable_allocs(&mut self, allocs: &LiveAllocs<'_, '_>) {
233233
self.root_ptr_tags.retain(|id, _| allocs.is_live(*id));
234234
}
235235
}
@@ -261,7 +261,7 @@ impl GlobalStateInner {
261261
id: AllocId,
262262
alloc_size: Size,
263263
kind: MemoryKind,
264-
machine: &MiriMachine<'_, '_>,
264+
machine: &MiriMachine<'_>,
265265
) -> AllocState {
266266
match self.borrow_tracker_method {
267267
BorrowTrackerMethod::StackedBorrows =>
@@ -276,8 +276,8 @@ impl GlobalStateInner {
276276
}
277277
}
278278

279-
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
280-
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
279+
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
280+
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
281281
fn retag_ptr_value(
282282
&mut self,
283283
kind: RetagKind,
@@ -354,7 +354,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
354354

355355
fn on_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();
@@ -431,7 +431,7 @@ impl AllocState {
431431
alloc_id: AllocId,
432432
prov_extra: ProvenanceExtra,
433433
range: AllocRange,
434-
machine: &MiriMachine<'_, 'tcx>,
434+
machine: &MiriMachine<'tcx>,
435435
) -> InterpResult<'tcx> {
436436
match self {
437437
AllocState::StackedBorrows(sb) =>
@@ -452,7 +452,7 @@ impl AllocState {
452452
alloc_id: AllocId,
453453
prov_extra: ProvenanceExtra,
454454
range: AllocRange,
455-
machine: &MiriMachine<'_, 'tcx>,
455+
machine: &MiriMachine<'tcx>,
456456
) -> InterpResult<'tcx> {
457457
match self {
458458
AllocState::StackedBorrows(sb) =>
@@ -473,7 +473,7 @@ impl AllocState {
473473
alloc_id: AllocId,
474474
prov_extra: ProvenanceExtra,
475475
size: Size,
476-
machine: &MiriMachine<'_, 'tcx>,
476+
machine: &MiriMachine<'tcx>,
477477
) -> InterpResult<'tcx> {
478478
match self {
479479
AllocState::StackedBorrows(sb) =>
@@ -493,7 +493,7 @@ impl AllocState {
493493
/// Tree Borrows needs to be told when a tag stops being protected.
494494
pub fn release_protector<'tcx>(
495495
&self,
496-
machine: &MiriMachine<'_, 'tcx>,
496+
machine: &MiriMachine<'tcx>,
497497
global: &GlobalState,
498498
tag: BorTag,
499499
alloc_id: AllocId, // diagnostics

src/borrow_tracker/stacked_borrows/diagnostics.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,29 @@ pub struct TagHistory {
115115
pub protected: Option<(String, SpanData)>,
116116
}
117117

118-
pub struct DiagnosticCxBuilder<'ecx, 'mir, 'tcx> {
118+
pub struct DiagnosticCxBuilder<'ecx, 'tcx> {
119119
operation: Operation,
120-
machine: &'ecx MiriMachine<'mir, 'tcx>,
120+
machine: &'ecx MiriMachine<'tcx>,
121121
}
122122

123-
pub struct DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
123+
pub struct DiagnosticCx<'history, 'ecx, 'tcx> {
124124
operation: Operation,
125-
machine: &'ecx MiriMachine<'mir, 'tcx>,
125+
machine: &'ecx MiriMachine<'tcx>,
126126
history: &'history mut AllocHistory,
127127
offset: Size,
128128
}
129129

130-
impl<'ecx, 'mir, 'tcx> DiagnosticCxBuilder<'ecx, 'mir, 'tcx> {
130+
impl<'ecx, 'tcx> DiagnosticCxBuilder<'ecx, 'tcx> {
131131
pub fn build<'history>(
132132
self,
133133
history: &'history mut AllocHistory,
134134
offset: Size,
135-
) -> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
135+
) -> DiagnosticCx<'history, 'ecx, 'tcx> {
136136
DiagnosticCx { operation: self.operation, machine: self.machine, history, offset }
137137
}
138138

139139
pub fn retag(
140-
machine: &'ecx MiriMachine<'mir, 'tcx>,
140+
machine: &'ecx MiriMachine<'tcx>,
141141
info: RetagInfo,
142142
new_tag: BorTag,
143143
orig_tag: ProvenanceExtra,
@@ -150,7 +150,7 @@ impl<'ecx, 'mir, 'tcx> DiagnosticCxBuilder<'ecx, 'mir, 'tcx> {
150150
}
151151

152152
pub fn read(
153-
machine: &'ecx MiriMachine<'mir, 'tcx>,
153+
machine: &'ecx MiriMachine<'tcx>,
154154
tag: ProvenanceExtra,
155155
range: AllocRange,
156156
) -> Self {
@@ -159,22 +159,22 @@ impl<'ecx, 'mir, 'tcx> DiagnosticCxBuilder<'ecx, 'mir, 'tcx> {
159159
}
160160

161161
pub fn write(
162-
machine: &'ecx MiriMachine<'mir, 'tcx>,
162+
machine: &'ecx MiriMachine<'tcx>,
163163
tag: ProvenanceExtra,
164164
range: AllocRange,
165165
) -> Self {
166166
let operation = Operation::Access(AccessOp { kind: AccessKind::Write, tag, range });
167167
DiagnosticCxBuilder { machine, operation }
168168
}
169169

170-
pub fn dealloc(machine: &'ecx MiriMachine<'mir, 'tcx>, tag: ProvenanceExtra) -> Self {
170+
pub fn dealloc(machine: &'ecx MiriMachine<'tcx>, tag: ProvenanceExtra) -> Self {
171171
let operation = Operation::Dealloc(DeallocOp { tag });
172172
DiagnosticCxBuilder { machine, operation }
173173
}
174174
}
175175

176-
impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
177-
pub fn unbuild(self) -> DiagnosticCxBuilder<'ecx, 'mir, 'tcx> {
176+
impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
177+
pub fn unbuild(self) -> DiagnosticCxBuilder<'ecx, 'tcx> {
178178
DiagnosticCxBuilder { machine: self.machine, operation: self.operation }
179179
}
180180
}
@@ -222,7 +222,7 @@ struct DeallocOp {
222222
}
223223

224224
impl AllocHistory {
225-
pub fn new(id: AllocId, item: Item, machine: &MiriMachine<'_, '_>) -> Self {
225+
pub fn new(id: AllocId, item: Item, machine: &MiriMachine<'_>) -> Self {
226226
Self {
227227
id,
228228
root: (item, machine.current_span()),
@@ -239,7 +239,7 @@ impl AllocHistory {
239239
}
240240
}
241241

242-
impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
242+
impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
243243
pub fn start_grant(&mut self, perm: Permission) {
244244
let Operation::Retag(op) = &mut self.operation else {
245245
unreachable!(

0 commit comments

Comments
 (0)