Skip to content

Commit eef9507

Browse files
committed
Rollup merge of rust-lang#55916 - RalfJung:mut-visitor, r=oli-obk
Make miri value visitor usfeful for mutation This is based on top of rust-lang#55716, [click here](RalfJung/rust@escape-to-raw...RalfJung:mut-visitor) for just the new commits. r? @oli-obk
2 parents 1d4c2a1 + e4d03f8 commit eef9507

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/librustc_mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ pub use self::machine::{Machine, AllocMap, MayLeak};
3939

4040
pub use self::operand::{ScalarMaybeUndef, Immediate, ImmTy, Operand, OpTy};
4141

42-
pub use self::visitor::ValueVisitor;
42+
pub use self::visitor::{ValueVisitor, MutValueVisitor};
4343

4444
pub use self::validity::RefTracking;

src/librustc_mir/interpret/validity.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc::mir::interpret::{
2121
};
2222

2323
use super::{
24-
OpTy, MPlaceTy, ImmTy, Machine, EvalContext, ValueVisitor
24+
OpTy, MPlaceTy, Machine, EvalContext, ValueVisitor
2525
};
2626

2727
macro_rules! validation_failure {
@@ -281,8 +281,9 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
281281
}
282282
}
283283

284-
fn visit_primitive(&mut self, value: ImmTy<'tcx, M::PointerTag>) -> EvalResult<'tcx>
284+
fn visit_primitive(&mut self, value: OpTy<'tcx, M::PointerTag>) -> EvalResult<'tcx>
285285
{
286+
let value = self.ecx.read_immediate(value)?;
286287
// Go over all the primitive types
287288
let ty = value.layout.ty;
288289
match ty.sty {

src/librustc_mir/interpret/visitor.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::mir::interpret::{
88
};
99

1010
use super::{
11-
Machine, EvalContext, MPlaceTy, OpTy, ImmTy,
11+
Machine, EvalContext, MPlaceTy, OpTy,
1212
};
1313

1414
// A thing that we can project into, and that has a layout.
@@ -201,9 +201,11 @@ macro_rules! make_value_visitor {
201201
{ Ok(()) }
202202

203203
/// Called whenever we reach a value of primitive type. There can be no recursion
204-
/// below such a value. This is the leave function.
204+
/// below such a value. This is the leaf function.
205+
/// We do *not* provide an `ImmTy` here because some implementations might want
206+
/// to write to the place this primitive lives in.
205207
#[inline(always)]
206-
fn visit_primitive(&mut self, _val: ImmTy<'tcx, M::PointerTag>) -> EvalResult<'tcx>
208+
fn visit_primitive(&mut self, _v: Self::V) -> EvalResult<'tcx>
207209
{ Ok(()) }
208210

209211
// Default recursors. Not meant to be overloaded.
@@ -279,9 +281,7 @@ macro_rules! make_value_visitor {
279281
_ => v.layout().ty.builtin_deref(true).is_some(),
280282
};
281283
if primitive {
282-
let op = v.to_op(self.ecx())?;
283-
let val = self.ecx().read_immediate(op)?;
284-
return self.visit_primitive(val);
284+
return self.visit_primitive(v);
285285
}
286286

287287
// Proceed into the fields.

0 commit comments

Comments
 (0)