Skip to content

Commit c3342b4

Browse files
committed
remove unnecessary frame parameter from after_local_allocated
1 parent 4497990 commit c3342b4

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::cell::Cell;
2-
use std::ptr;
32
use std::{fmt, mem};
43

54
use either::{Either, Left, Right};
@@ -278,9 +277,11 @@ impl<'mir, 'tcx, Prov: Provenance, Extra> Frame<'mir, 'tcx, Prov, Extra> {
278277
})
279278
}
280279

280+
/// Returns the address of the buffer where the locals are stored. This is used by `Place` as a
281+
/// sanity check to detect bugs where we mix up which stack frame a place refers to.
281282
#[inline(always)]
282283
pub(super) fn locals_addr(&self) -> usize {
283-
ptr::addr_of!(self.locals).addr()
284+
self.locals.raw.as_ptr().addr()
284285
}
285286
}
286287

compiler/rustc_const_eval/src/interpret/machine.rs

-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
508508
#[inline(always)]
509509
fn after_local_allocated(
510510
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
511-
_frame: usize,
512511
_local: mir::Local,
513512
_mplace: &MPlaceTy<'tcx, Self::Provenance>,
514513
) -> InterpResult<'tcx> {

compiler/rustc_const_eval/src/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ where
940940
mplace.mplace,
941941
)?;
942942
}
943-
M::after_local_allocated(self, self.frame_idx(), local, &mplace)?;
943+
M::after_local_allocated(self, local, &mplace)?;
944944
// Now we can call `access_mut` again, asserting it goes well, and actually
945945
// overwrite things. This points to the entire allocation, not just the part
946946
// the place refers to, i.e. we do this before we apply `offset`.

src/tools/miri/src/machine.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1473,14 +1473,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
14731473

14741474
fn after_local_allocated(
14751475
ecx: &mut InterpCx<'mir, 'tcx, Self>,
1476-
frame: usize,
14771476
local: mir::Local,
14781477
mplace: &MPlaceTy<'tcx, Provenance>,
14791478
) -> InterpResult<'tcx> {
14801479
let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr().provenance else {
14811480
panic!("after_local_allocated should only be called on fresh allocations");
14821481
};
1483-
let local_decl = &ecx.active_thread_stack()[frame].body.local_decls[local];
1482+
let local_decl = &ecx.frame().body.local_decls[local];
14841483
let span = local_decl.source_info.span;
14851484
ecx.machine.allocation_spans.borrow_mut().insert(alloc_id, (span, None));
14861485
Ok(())

0 commit comments

Comments
 (0)