Skip to content

Commit aff9841

Browse files
committed
remove a now-useless machine hook
1 parent 4173e97 commit aff9841

File tree

4 files changed

+5
-33
lines changed

4 files changed

+5
-33
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

-3
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ pub enum LocalValue<Prov: Provenance = AllocId> {
187187

188188
impl<'tcx, Prov: Provenance + 'static> LocalState<'tcx, Prov> {
189189
/// Read the local's value or error if the local is not yet live or not live anymore.
190-
///
191-
/// Note: This may only be invoked from the `Machine::access_local` hook and not from
192-
/// anywhere else. You may be invalidating machine invariants if you do!
193190
#[inline]
194191
pub fn access(&self) -> InterpResult<'tcx, &Operand<Prov>> {
195192
match &self.value {

compiler/rustc_const_eval/src/interpret/machine.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,12 @@ pub trait Machine<'mir, 'tcx>: Sized {
215215
right: &ImmTy<'tcx, Self::Provenance>,
216216
) -> InterpResult<'tcx, (Scalar<Self::Provenance>, bool, Ty<'tcx>)>;
217217

218-
/// Called to read the specified `local` from the `frame`.
219-
/// Since reading a ZST is not actually accessing memory or locals, this is never invoked
220-
/// for ZST reads.
221-
#[inline]
222-
fn access_local<'a>(
223-
frame: &'a Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
224-
local: mir::Local,
225-
) -> InterpResult<'tcx, &'a Operand<Self::Provenance>>
226-
where
227-
'tcx: 'mir,
228-
{
229-
frame.locals[local].access()
230-
}
231-
232218
/// Called to write the specified `local` from the `frame`.
233219
/// Since writing a ZST is not actually accessing memory or locals, this is never invoked
234220
/// for ZST reads.
221+
///
222+
/// Due to borrow checker trouble, we indicate the `frame` as an index rather than an `&mut
223+
/// Frame`.
235224
#[inline]
236225
fn access_local_mut<'a>(
237226
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,

compiler/rustc_const_eval/src/interpret/operand.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
444444
}
445445
}
446446

447-
/// Read from a local. Will not actually access the local if reading from a ZST.
447+
/// Read from a local.
448448
/// Will not access memory, instead an indirect `Operand` is returned.
449449
///
450450
/// This is public because it is used by [priroda](https://github.com/oli-obk/priroda) to get an
@@ -456,12 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
456456
layout: Option<TyAndLayout<'tcx>>,
457457
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
458458
let layout = self.layout_of_local(frame, local, layout)?;
459-
let op = if layout.is_zst() {
460-
// Bypass `access_local` (helps in ConstProp)
461-
Operand::Immediate(Immediate::Uninit)
462-
} else {
463-
*M::access_local(frame, local)?
464-
};
459+
let op = *frame.locals[local].access()?;
465460
Ok(OpTy { op, layout, align: Some(layout.align.abi) })
466461
}
467462

compiler/rustc_mir_transform/src/const_prop.rs

-9
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
243243
throw_machine_stop_str!("pointer arithmetic or comparisons aren't supported in ConstProp")
244244
}
245245

246-
fn access_local<'a>(
247-
frame: &'a Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
248-
local: Local,
249-
) -> InterpResult<'tcx, &'a interpret::Operand<Self::Provenance>> {
250-
let l = &frame.locals[local];
251-
// Applying restrictions here is meaningless since they can be circumvented via `force_allocation`.
252-
l.access()
253-
}
254-
255246
fn access_local_mut<'a>(
256247
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
257248
frame: usize,

0 commit comments

Comments
 (0)