Skip to content

Commit cb09fab

Browse files
committed
Auto merge of #799 - rust-lang:rustup, r=RalfJung
Initialize MemoryExtra with StdRng We need this in a local branch for an synchronous rustc update.
2 parents ad83707 + ba8728c commit cb09fab

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24a9bcbb7cb0d8bdc11b8252a9c13f7562c7e4ca
1+
481068a707679257e2a738b40987246e0420e787

src/eval.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Main evaluator loop and setting up the initial stack frame.
2+
13
use rand::rngs::StdRng;
24
use rand::SeedableRng;
35

@@ -29,23 +31,22 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
2931
main_id: DefId,
3032
config: MiriConfig,
3133
) -> InterpResult<'tcx, InterpCx<'mir, 'tcx, Evaluator<'tcx>>> {
32-
let mut ecx = InterpCx::new(
33-
tcx.at(syntax::source_map::DUMMY_SP),
34-
ty::ParamEnv::reveal_all(),
35-
Evaluator::new(),
36-
);
3734

3835
// FIXME(https://github.com/rust-lang/miri/pull/803): no validation on Windows.
39-
let target_os = ecx.tcx.tcx.sess.target.target.target_os.to_lowercase();
36+
let target_os = tcx.sess.target.target.target_os.to_lowercase();
4037
let validate = if target_os == "windows" {
4138
false
4239
} else {
4340
config.validate
4441
};
4542

46-
// FIXME: InterpCx::new should take an initial MemoryExtra
47-
ecx.memory_mut().extra = MemoryExtra::new(config.seed.map(StdRng::seed_from_u64), validate);
48-
43+
let mut ecx = InterpCx::new(
44+
tcx.at(syntax::source_map::DUMMY_SP),
45+
ty::ParamEnv::reveal_all(),
46+
Evaluator::new(),
47+
MemoryExtra::new(config.seed.map(StdRng::seed_from_u64), validate),
48+
);
49+
4950
let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id);
5051
let main_mir = ecx.load_mir(main_instance.def)?;
5152

src/machine.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Global machine state as well as implementation of the interpreter engine
2+
//! `Machine` trait.
3+
14
use std::rc::Rc;
25
use std::borrow::Cow;
36
use std::collections::HashMap;
@@ -48,7 +51,7 @@ pub struct AllocExtra {
4851
}
4952

5053
/// Extra global memory data
51-
#[derive(Default, Clone, Debug)]
54+
#[derive(Clone, Debug)]
5255
pub struct MemoryExtra {
5356
pub stacked_borrows: stacked_borrows::MemoryExtra,
5457
pub intptrcast: intptrcast::MemoryExtra,

src/range_map.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unused)]
2-
31
//! Implements a map from integer indices to data.
42
//! Rather than storing data for every index, internally, this maps entire ranges to the data.
53
//! To this end, the APIs all work on ranges, not on individual integers. Ranges are split as
@@ -8,7 +6,6 @@
86
//! via the iteration APIs.
97
108
use std::ops;
11-
use std::num::NonZeroU64;
129

1310
use rustc::ty::layout::Size;
1411

@@ -158,7 +155,7 @@ impl<T> RangeMap<T> {
158155
let mut end_idx = first_idx; // when the loop is done, this is the first excluded element.
159156
loop {
160157
// Compute if `end` is the last element we need to look at.
161-
let done = (self.v[end_idx].range.end >= offset+len);
158+
let done = self.v[end_idx].range.end >= offset+len;
162159
// We definitely need to include `end`, so move the index.
163160
end_idx += 1;
164161
debug_assert!(done || end_idx < self.v.len(), "iter_mut: end-offset {} is out-of-bounds", offset+len);
@@ -284,7 +281,7 @@ mod tests {
284281
.map(|&t| t).collect::<Vec<_>>(), vec![19, 19]);
285282

286283
// A NOP `iter_mut` should trigger merging.
287-
for x in map.iter_mut(Size::from_bytes(15), Size::from_bytes(5)) { }
284+
for _ in map.iter_mut(Size::from_bytes(15), Size::from_bytes(5)) { }
288285
assert_eq!(map.v.len(), 5);
289286
assert_eq!(
290287
to_vec(&map, 10, 10),

src/shims/tls.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Implement thread-local storage.
2+
13
use std::collections::BTreeMap;
24

35
use rustc_target::abi::LayoutOf;

src/stacked_borrows.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Implements "Stacked Borrows". See <https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md>
2+
//! for further information.
3+
14
use std::cell::RefCell;
25
use std::collections::{HashMap, HashSet};
36
use std::rc::Rc;

tests/run-pass/move-undef-primval.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(deprecated)]
2+
13
struct Foo {
24
_inner: i32,
35
}

0 commit comments

Comments
 (0)