Skip to content

Commit 0837d63

Browse files
committed
Some final cleanup
1 parent c6e0d09 commit 0837d63

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/fn_call.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
213213
"syscall" => {
214214
let sys_getrandom = this.eval_path_scalar(&["libc", "SYS_getrandom"])?
215215
.expect("Failed to get libc::SYS_getrandom")
216-
.to_usize(this)? as i64;
216+
.to_usize(this)?;
217217

218218
// `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
219219
// is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
220-
match this.read_scalar(args[0])?.to_usize(this)? as i64 {
220+
match this.read_scalar(args[0])?.to_usize(this)? {
221221
id if id == sys_getrandom => {
222222
let ptr = this.read_scalar(args[1])?.to_ptr()?;
223223
let len = this.read_scalar(args[2])?.to_usize(this)?;
@@ -795,13 +795,15 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
795795
}
796796
}
797797

798-
fn gen_random<'a, 'mir, 'tcx>(this: &mut MiriEvalContext<'a, 'mir, 'tcx>,
799-
len: usize) -> Result<Vec<u8>, EvalError<'tcx>> {
798+
fn gen_random<'a, 'mir, 'tcx>(
799+
this: &mut MiriEvalContext<'a, 'mir, 'tcx>,
800+
len: usize,
801+
) -> Result<Vec<u8>, EvalError<'tcx>> {
800802

801-
match this.machine.rng.as_ref() {
803+
match &mut this.machine.rng {
802804
Some(rng) => {
803805
let mut data = vec![0; len];
804-
rng.borrow_mut().fill_bytes(&mut data);
806+
rng.fill_bytes(&mut data);
805807
Ok(data)
806808
}
807809
None => {

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ mod stacked_borrows;
2323

2424
use std::collections::HashMap;
2525
use std::borrow::Cow;
26-
use std::cell::RefCell;
2726

2827
use rand::rngs::StdRng;
2928
use rand::SeedableRng;
@@ -336,7 +335,7 @@ pub struct Evaluator<'tcx> {
336335

337336
/// The random number generator to use if Miri
338337
/// is running in non-deterministic mode
339-
pub(crate) rng: Option<RefCell<StdRng>>
338+
pub(crate) rng: Option<StdRng>
340339
}
341340

342341
impl<'tcx> Evaluator<'tcx> {
@@ -350,7 +349,7 @@ impl<'tcx> Evaluator<'tcx> {
350349
tls: TlsData::default(),
351350
validate,
352351
stacked_borrows: stacked_borrows::State::default(),
353-
rng: seed.map(|s| RefCell::new(StdRng::seed_from_u64(s)))
352+
rng: seed.map(|s| StdRng::seed_from_u64(s))
354353
}
355354
}
356355
}

0 commit comments

Comments
 (0)