Skip to content

Commit 715ffab

Browse files
committed
InterpCx: make memory field public
1 parent d4f7f97 commit 715ffab

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

src/librustc_mir/interpret/eval_context.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
3535
pub(crate) param_env: ty::ParamEnv<'tcx>,
3636

3737
/// The virtual memory system.
38-
pub(crate) memory: Memory<'mir, 'tcx, M>,
38+
pub memory: Memory<'mir, 'tcx, M>,
3939

4040
/// The virtual call stack.
4141
pub(crate) stack: Vec<Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>>,
@@ -211,16 +211,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
211211
}
212212
}
213213

214-
#[inline(always)]
215-
pub fn memory(&self) -> &Memory<'mir, 'tcx, M> {
216-
&self.memory
217-
}
218-
219-
#[inline(always)]
220-
pub fn memory_mut(&mut self) -> &mut Memory<'mir, 'tcx, M> {
221-
&mut self.memory
222-
}
223-
224214
#[inline(always)]
225215
pub fn force_ptr(
226216
&self,

src/librustc_mir/interpret/intern.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ fn intern_shallow<'rt, 'mir, 'tcx>(
7373
);
7474
// remove allocation
7575
let tcx = ecx.tcx;
76-
let memory = ecx.memory_mut();
77-
let (kind, mut alloc) = match memory.alloc_map.remove(&alloc_id) {
76+
let (kind, mut alloc) = match ecx.memory.alloc_map.remove(&alloc_id) {
7877
Some(entry) => entry,
7978
None => {
8079
// Pointer not found in local memory map. It is either a pointer to the global
@@ -332,7 +331,7 @@ pub fn intern_const_alloc_recursive(
332331

333332
let mut todo: Vec<_> = leftover_allocations.iter().cloned().collect();
334333
while let Some(alloc_id) = todo.pop() {
335-
if let Some((_, mut alloc)) = ecx.memory_mut().alloc_map.remove(&alloc_id) {
334+
if let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) {
336335
// We can't call the `intern_shallow` method here, as its logic is tailored to safe
337336
// references and a `leftover_allocations` set (where we only have a todo-list here).
338337
// So we hand-roll the interning logic here again.
@@ -350,7 +349,7 @@ pub fn intern_const_alloc_recursive(
350349
todo.push(reloc);
351350
}
352351
}
353-
} else if ecx.memory().dead_alloc_map.contains_key(&alloc_id) {
352+
} else if ecx.memory.dead_alloc_map.contains_key(&alloc_id) {
354353
// dangling pointer
355354
throw_unsup!(ValidationFailure("encountered dangling pointer in final constant".into()))
356355
}

src/librustc_mir/interpret/terminator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
140140
.read_immediate(self.eval_operand(len, None)?)
141141
.expect("can't eval len")
142142
.to_scalar()?
143-
.to_bits(self.memory().pointer_size())? as u64;
143+
.to_bits(self.memory.pointer_size())? as u64;
144144
let index = self
145145
.read_immediate(self.eval_operand(index, None)?)
146146
.expect("can't eval index")
147147
.to_scalar()?
148-
.to_bits(self.memory().pointer_size())? as u64;
148+
.to_bits(self.memory.pointer_size())? as u64;
149149
err_panic!(BoundsCheck { len, index })
150150
}
151151
Overflow(op) => err_panic!(Overflow(*op)),

0 commit comments

Comments
 (0)