Skip to content

Commit 413a351

Browse files
committed
Initialize MemoryExtra with StdRng
1 parent 945f007 commit 413a351

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use crate::range_map::RangeMap;
5050
pub use crate::helpers::{EvalContextExt as HelpersEvalContextExt};
5151
use crate::mono_hash_map::MonoHashMap;
5252
pub use crate::stacked_borrows::{EvalContextExt as StackedBorEvalContextExt};
53-
use crate::memory::AllocExtra;
53+
use crate::memory::{MemoryExtra, AllocExtra};
5454

5555
// Used by priroda.
5656
pub use crate::stacked_borrows::{Tag, Permission, Stack, Stacks, Item};
@@ -83,10 +83,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
8383
tcx.at(syntax::source_map::DUMMY_SP),
8484
ty::ParamEnv::reveal_all(),
8585
Evaluator::new(config.validate),
86+
MemoryExtra::with_rng(config.seed.map(StdRng::seed_from_u64)),
8687
);
87-
88-
// FIXME: InterpretCx::new should take an initial MemoryExtra
89-
ecx.memory_mut().extra.rng = config.seed.map(StdRng::seed_from_u64);
9088

9189
let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id);
9290
let main_mir = ecx.load_mir(main_instance.def)?;

src/memory.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ pub struct MemoryExtra {
1515
pub(crate) rng: Option<StdRng>
1616
}
1717

18+
impl MemoryExtra {
19+
pub fn with_rng(rng: Option<StdRng>) -> Self {
20+
MemoryExtra {
21+
stacked_borrows: Default::default(),
22+
intptrcast: Default::default(),
23+
rng,
24+
}
25+
}
26+
}
27+
1828
#[derive(Debug, Clone)]
1929
pub struct AllocExtra {
2030
pub stacked_borrows: stacked_borrows::AllocExtra,

0 commit comments

Comments
 (0)