Skip to content

Commit

Permalink
remove unnecessary frame parameter from after_local_allocated
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 10, 2024
1 parent 4497990 commit c3342b4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_const_eval/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::cell::Cell;
use std::ptr;
use std::{fmt, mem};

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

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

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
#[inline(always)]
fn after_local_allocated(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
_frame: usize,
_local: mir::Local,
_mplace: &MPlaceTy<'tcx, Self::Provenance>,
) -> InterpResult<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ where
mplace.mplace,
)?;
}
M::after_local_allocated(self, self.frame_idx(), local, &mplace)?;
M::after_local_allocated(self, local, &mplace)?;
// Now we can call `access_mut` again, asserting it goes well, and actually
// overwrite things. This points to the entire allocation, not just the part
// the place refers to, i.e. we do this before we apply `offset`.
Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1473,14 +1473,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {

fn after_local_allocated(
ecx: &mut InterpCx<'mir, 'tcx, Self>,
frame: usize,
local: mir::Local,
mplace: &MPlaceTy<'tcx, Provenance>,
) -> InterpResult<'tcx> {
let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr().provenance else {
panic!("after_local_allocated should only be called on fresh allocations");
};
let local_decl = &ecx.active_thread_stack()[frame].body.local_decls[local];
let local_decl = &ecx.frame().body.local_decls[local];
let span = local_decl.source_info.span;
ecx.machine.allocation_spans.borrow_mut().insert(alloc_id, (span, None));
Ok(())
Expand Down

0 comments on commit c3342b4

Please sign in to comment.