Skip to content

Commit 25ddc65

Browse files
committed
move validate field from memory to machine
1 parent 274ae04 commit 25ddc65

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/eval.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
5050
let mut ecx = InterpCx::new(
5151
tcx.at(rustc_span::source_map::DUMMY_SP),
5252
ty::ParamEnv::reveal_all(),
53-
Evaluator::new(config.communicate),
53+
Evaluator::new(
54+
config.communicate,
55+
config.validate,
56+
),
5457
MemoryExtra::new(
5558
StdRng::seed_from_u64(config.seed.unwrap_or(0)),
56-
config.validate,
5759
config.stacked_borrows,
5860
config.tracked_pointer_tag,
5961
),

src/machine.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,10 @@ pub struct MemoryExtra {
7676

7777
/// The random number generator used for resolving non-determinism.
7878
pub(crate) rng: RefCell<StdRng>,
79-
80-
/// Whether to enforce the validity invariant.
81-
pub(crate) validate: bool,
8279
}
8380

8481
impl MemoryExtra {
85-
pub fn new(rng: StdRng, validate: bool, stacked_borrows: bool, tracked_pointer_tag: Option<PtrId>) -> Self {
82+
pub fn new(rng: StdRng, stacked_borrows: bool, tracked_pointer_tag: Option<PtrId>) -> Self {
8683
let stacked_borrows = if stacked_borrows {
8784
Some(Rc::new(RefCell::new(stacked_borrows::GlobalState::new(tracked_pointer_tag))))
8885
} else {
@@ -92,7 +89,6 @@ impl MemoryExtra {
9289
stacked_borrows,
9390
intptrcast: Default::default(),
9491
rng: RefCell::new(rng),
95-
validate,
9692
}
9793
}
9894
}
@@ -120,6 +116,9 @@ pub struct Evaluator<'tcx> {
120116
/// and random number generation is delegated to the host.
121117
pub(crate) communicate: bool,
122118

119+
/// Whether to enforce the validity invariant.
120+
pub(crate) validate: bool,
121+
123122
pub(crate) file_handler: FileHandler,
124123

125124
/// The temporary used for storing the argument of
@@ -128,7 +127,7 @@ pub struct Evaluator<'tcx> {
128127
}
129128

130129
impl<'tcx> Evaluator<'tcx> {
131-
pub(crate) fn new(communicate: bool) -> Self {
130+
pub(crate) fn new(communicate: bool, validate: bool) -> Self {
132131
Evaluator {
133132
// `env_vars` could be initialized properly here if `Memory` were available before
134133
// calling this method.
@@ -139,6 +138,7 @@ impl<'tcx> Evaluator<'tcx> {
139138
last_error: None,
140139
tls: TlsData::default(),
141140
communicate,
141+
validate,
142142
file_handler: Default::default(),
143143
panic_payload: None,
144144
}
@@ -183,7 +183,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
183183

184184
#[inline(always)]
185185
fn enforce_validity(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
186-
ecx.memory.extra.validate
186+
ecx.machine.validate
187187
}
188188

189189
#[inline(always)]

0 commit comments

Comments
 (0)