Skip to content

Commit 4497990

Browse files
committed
remove some frame parameters that are no longer needed
1 parent b888e89 commit 4497990

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
648648
}
649649

650650
#[inline(always)]
651-
pub fn layout_of_local(
651+
pub(super) fn layout_of_local(
652652
&self,
653653
frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>,
654654
local: mir::Local,
@@ -899,7 +899,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
899899
// Copy return value. Must of course happen *before* we deallocate the locals.
900900
let copy_ret_result = if !unwinding {
901901
let op = self
902-
.local_to_op(self.frame(), mir::RETURN_PLACE, None)
902+
.local_to_op(mir::RETURN_PLACE, None)
903903
.expect("return place should always be live");
904904
let dest = self.frame().return_place.clone();
905905
let err = if self.stack().len() == 1 {

compiler/rustc_const_eval/src/interpret/operand.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use rustc_middle::{mir, ty};
1313
use rustc_target::abi::{self, Abi, HasDataLayout, Size};
1414

1515
use super::{
16-
alloc_range, from_known_layout, mir_assign_valid_types, CtfeProvenance, Frame, InterpCx,
17-
InterpResult, MPlaceTy, Machine, MemPlace, MemPlaceMeta, OffsetMode, PlaceTy, Pointer,
18-
Projectable, Provenance, Scalar,
16+
alloc_range, from_known_layout, mir_assign_valid_types, CtfeProvenance, InterpCx, InterpResult,
17+
MPlaceTy, Machine, MemPlace, MemPlaceMeta, OffsetMode, PlaceTy, Pointer, Projectable,
18+
Provenance, Scalar,
1919
};
2020

2121
/// An `Immediate` represents a single immediate self-contained Rust value.
@@ -633,17 +633,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
633633
}
634634
}
635635

636-
/// Read from a local.
636+
/// Read from a local of the current frame.
637637
/// Will not access memory, instead an indirect `Operand` is returned.
638638
///
639639
/// This is public because it is used by [priroda](https://github.com/oli-obk/priroda) to get an
640640
/// OpTy from a local.
641641
pub fn local_to_op(
642642
&self,
643-
frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>,
644643
local: mir::Local,
645644
layout: Option<TyAndLayout<'tcx>>,
646645
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
646+
let frame = self.frame();
647647
let layout = self.layout_of_local(frame, local, layout)?;
648648
let op = *frame.locals[local].access()?;
649649
if matches!(op, Operand::Immediate(_)) {
@@ -664,7 +664,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
664664
Right((local, offset, locals_addr)) => {
665665
debug_assert!(place.layout.is_sized()); // only sized locals can ever be `Place::Local`.
666666
debug_assert_eq!(locals_addr, self.frame().locals_addr());
667-
let base = self.local_to_op(&self.frame(), local, None)?;
667+
let base = self.local_to_op(local, None)?;
668668
Ok(match offset {
669669
Some(offset) => base.offset(offset, place.layout, self)?,
670670
None => {
@@ -688,7 +688,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
688688
// here is not the entire place.
689689
let layout = if mir_place.projection.is_empty() { layout } else { None };
690690

691-
let mut op = self.local_to_op(self.frame(), mir_place.local, layout)?;
691+
let mut op = self.local_to_op(mir_place.local, layout)?;
692692
// Using `try_fold` turned out to be bad for performance, hence the loop.
693693
for elem in mir_place.projection.iter() {
694694
op = self.project(&op, elem)?

compiler/rustc_const_eval/src/interpret/place.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -506,21 +506,21 @@ where
506506
Ok((mplace, len))
507507
}
508508

509+
/// Turn a local in the current frame into a place.
509510
pub fn local_to_place(
510511
&self,
511-
frame: usize,
512512
local: mir::Local,
513513
) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> {
514514
// Other parts of the system rely on `Place::Local` never being unsized.
515515
// So we eagerly check here if this local has an MPlace, and if yes we use it.
516-
let frame_ref = &self.stack()[frame];
517-
let layout = self.layout_of_local(frame_ref, local, None)?;
516+
let frame = self.frame();
517+
let layout = self.layout_of_local(frame, local, None)?;
518518
let place = if layout.is_sized() {
519519
// We can just always use the `Local` for sized values.
520-
Place::Local { local, offset: None, locals_addr: frame_ref.locals_addr() }
520+
Place::Local { local, offset: None, locals_addr: frame.locals_addr() }
521521
} else {
522522
// Unsized `Local` isn't okay (we cannot store the metadata).
523-
match frame_ref.locals[local].access()? {
523+
match frame.locals[local].access()? {
524524
Operand::Immediate(_) => bug!(),
525525
Operand::Indirect(mplace) => Place::Ptr(*mplace),
526526
}
@@ -535,7 +535,7 @@ where
535535
&self,
536536
mir_place: mir::Place<'tcx>,
537537
) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> {
538-
let mut place = self.local_to_place(self.frame_idx(), mir_place.local)?;
538+
let mut place = self.local_to_place(mir_place.local)?;
539539
// Using `try_fold` turned out to be bad for performance, hence the loop.
540540
for elem in mir_place.projection.iter() {
541541
place = self.project(&place, elem)?

compiler/rustc_const_eval/src/interpret/projection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ where
357357
Deref => self.deref_pointer(&base.to_op(self)?)?.into(),
358358
Index(local) => {
359359
let layout = self.layout_of(self.tcx.types.usize)?;
360-
let n = self.local_to_op(self.frame(), local, Some(layout))?;
360+
let n = self.local_to_op(local, Some(layout))?;
361361
let n = self.read_target_usize(&n)?;
362362
self.project_index(base, n)?
363363
}

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
631631
body.args_iter()
632632
.map(|local| (
633633
local,
634-
self.layout_of_local(self.frame(), local, None).unwrap().ty
634+
self.layout_of_local(self.frame(), local, None).unwrap().ty,
635635
))
636636
.collect::<Vec<_>>()
637637
);

src/tools/miri/src/helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
411411
.ok_or_else(|| err_ub_format!("callee has fewer arguments than expected"))?;
412412
// Make the local live, and insert the initial value.
413413
this.storage_live(local)?;
414-
let callee_arg = this.local_to_place(this.frame_idx(), local)?;
414+
let callee_arg = this.local_to_place(local)?;
415415
this.write_immediate(*arg, &callee_arg)?;
416416
}
417417
if callee_args.next().is_some() {

0 commit comments

Comments
 (0)