Skip to content

Commit 10b9373

Browse files
committed
Fix merge conflicts
2 parents 4bbaa72 + 8355437 commit 10b9373

40 files changed

+391
-227
lines changed

.appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ install:
2828
- set PATH=%USERPROFILE%\.cargo\bin;%PATH%
2929
- rustup default stable
3030
- rustup uninstall beta
31-
- rustup component remove rust-docs & exit 0
3231
- rustup update
3332
# Install "master" toolchain
3433
- cargo install rustup-toolchain-install-master & exit 0
35-
- rustup-toolchain-install-master -f -n master %RUSTC_HASH% -c cargo -c rust-src
34+
# We need to install cargo here as well or else the DLL search path inside `cargo run`
35+
# will be for the wrong toolchain. (On Unix, `./miri` takes care of this, but not here.)
36+
- rustup-toolchain-install-master -f -n master %RUSTC_HASH% -c rust-src -c rustc-dev -c cargo
3637
- rustup default master
3738
- rustc --version
3839
- cargo --version

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ before_script:
3535
- export PATH=$HOME/.cargo/bin:$PATH
3636
- rustup default stable
3737
- rustup uninstall beta
38-
- rustup component remove rust-docs || echo "rust-docs already gone"
3938
- rustup update
4039
# Install "master" toolchain
4140
- cargo install rustup-toolchain-install-master || echo "rustup-toolchain-install-master already installed"
42-
- travis_retry rustup-toolchain-install-master -f -n master $RUSTC_HASH -c rust-src
41+
- travis_retry rustup-toolchain-install-master -f -n master $RUSTC_HASH -c rust-src -c rustc-dev
4342
- rustup default master
4443
- rustc --version
4544
- cargo --version

CONTRIBUTING.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ Miri heavily relies on internal rustc interfaces to execute MIR. Still, some
3131
things (like adding support for a new intrinsic or a shim for an external
3232
function being called) can be done by working just on the Miri side.
3333

34-
To prepare, make sure you are using a nightly Rust compiler. Then you should be
35-
able to just `cargo build` Miri.
34+
To prepare, make sure you are using a nightly Rust compiler. You also need to
35+
have the `rust-src` and `rustc-dev` components installed, which you can add via
36+
`rustup component add rust-src rustc-dev`. Then you should be able to just
37+
`cargo build` Miri.
3638

3739
In case this fails, your nightly might be incompatible with Miri master. The
3840
`rust-version` file contains the commit hash of rustc that Miri is currently
@@ -41,7 +43,7 @@ to wait for the next nightly to get released. You can also use
4143
[`rustup-toolchain-install-master`](https://github.com/kennytm/rustup-toolchain-install-master)
4244
to install that exact version of rustc as a toolchain:
4345
```
44-
rustup-toolchain-install-master $(cat rust-version) -c rust-src
46+
rustup-toolchain-install-master $(cat rust-version) -c rust-src -c rustc-dev
4547
```
4648

4749
Another common problem is outdated dependencies: Miri does not come with a

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ doctest = false # and no doc tests
3030
required-features = ["rustc_tests"]
3131

3232
[dependencies]
33-
cargo_metadata = { version = "0.8", optional = true }
33+
cargo_metadata = { version = "0.9.0", optional = true }
3434
directories = { version = "2.0", optional = true }
3535
rustc_version = { version = "0.2.3", optional = true }
3636
getrandom = { version = "0.1.8", features = ["std"] }
3737
byteorder = "1.3"
38-
env_logger = "0.6"
38+
env_logger = "0.7.1"
3939
log = "0.4"
4040
shell-escape = "0.1.4"
41-
hex = "0.3.2"
41+
hex = "0.4.0"
4242
rand = "0.7"
4343

4444
# A noop dependency that changes in the Rust repository, it's a bit of a hack.

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
55e00631e5bc5b16d40232914e57deeea197a8e4
1+
9e346646e93cc243567e27bb0f4e8716d56ad1f1

src/bin/cargo-miri.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::path::{PathBuf, Path};
66
use std::process::Command;
77
use std::ops::Not;
88

9+
const XARGO_MIN_VERSION: (u32, u32, u32) = (0, 3, 17);
10+
911
const CARGO_MIRI_HELP: &str = r#"Interprets bin crates and tests in Miri
1012
1113
Usage:
@@ -258,7 +260,7 @@ fn setup(ask_user: bool) {
258260
}
259261

260262
// First, we need xargo.
261-
if xargo_version().map_or(true, |v| v < (0, 3, 16)) {
263+
if xargo_version().map_or(true, |v| v < XARGO_MIN_VERSION) {
262264
if std::env::var("XARGO").is_ok() {
263265
// The user manually gave us a xargo binary; don't do anything automatically.
264266
show_error(format!("Your xargo is too old; please upgrade to the latest version"))

src/eval.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use rand::rngs::StdRng;
44
use rand::SeedableRng;
55

66
use rustc::hir::def_id::DefId;
7-
use rustc::ty::layout::{Align, LayoutOf, Size};
7+
use rustc::ty::layout::{LayoutOf, Size};
88
use rustc::ty::{self, TyCtxt};
99
use syntax::source_map::DUMMY_SP;
1010

1111
use crate::{
12-
struct_error, EnvVars, Evaluator, FnVal, HelpersEvalContextExt, InterpCx, InterpError,
12+
EnvVars, Evaluator, FnVal, HelpersEvalContextExt, InterpCx, InterpError,
1313
InterpResult, MemoryExtra, MiriMemoryKind, Pointer, Scalar, StackPopCleanup, Tag,
1414
TlsEvalContextExt,
1515
};
@@ -48,7 +48,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
4848
EnvVars::init(&mut ecx, config.excluded_env_vars);
4949

5050
// Setup first stack-frame
51-
let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id);
51+
let main_instance = ty::Instance::mono(tcx, main_id);
5252
let main_mir = ecx.load_mir(main_instance.def, None)?;
5353

5454
if !main_mir.return_ty().is_unit() || main_mir.arg_count != 0 {
@@ -59,11 +59,10 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
5959
let main_ret_ty = tcx.fn_sig(main_id).output();
6060
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
6161
let start_instance = ty::Instance::resolve(
62-
ecx.tcx.tcx,
62+
tcx,
6363
ty::ParamEnv::reveal_all(),
6464
start_id,
65-
ecx.tcx
66-
.mk_substs(::std::iter::once(ty::subst::GenericArg::from(main_ret_ty))),
65+
tcx.mk_substs(::std::iter::once(ty::subst::GenericArg::from(main_ret_ty))),
6766
)
6867
.unwrap();
6968
let start_mir = ecx.load_mir(start_instance.def, None)?;
@@ -106,7 +105,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
106105
{
107106
let argc_place = ecx.allocate(dest.layout, MiriMemoryKind::Env.into());
108107
ecx.write_scalar(argc, argc_place.into())?;
109-
ecx.machine.argc = Some(argc_place.ptr.to_ptr()?);
108+
ecx.machine.argc = Some(argc_place.ptr);
110109
}
111110

112111
// Third argument (`argv`): created from `config.args`.
@@ -134,8 +133,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
134133
}
135134
// Make an array with all these pointers, in the Miri memory.
136135
let argvs_layout = ecx.layout_of(
137-
ecx.tcx
138-
.mk_array(ecx.tcx.mk_imm_ptr(ecx.tcx.types.u8), argvs.len() as u64),
136+
tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), argvs.len() as u64),
139137
)?;
140138
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Env.into());
141139
for (idx, arg) in argvs.into_iter().enumerate() {
@@ -151,36 +149,26 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
151149
{
152150
let argv_place = ecx.allocate(dest.layout, MiriMemoryKind::Env.into());
153151
ecx.write_scalar(argv, argv_place.into())?;
154-
ecx.machine.argv = Some(argv_place.ptr.to_ptr()?);
152+
ecx.machine.argv = Some(argv_place.ptr);
155153
}
156154
// Store command line as UTF-16 for Windows `GetCommandLineW`.
157155
{
158156
let cmd_utf16: Vec<u16> = cmd.encode_utf16().collect();
159-
let cmd_ptr = ecx.memory.allocate(
160-
Size::from_bytes(cmd_utf16.len() as u64 * 2),
161-
Align::from_bytes(2).unwrap(),
162-
MiriMemoryKind::Env.into(),
163-
);
164-
ecx.machine.cmd_line = Some(cmd_ptr);
157+
let cmd_type = tcx.mk_array(tcx.types.u16, cmd_utf16.len() as u64);
158+
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Env.into());
159+
ecx.machine.cmd_line = Some(cmd_place.ptr);
165160
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
166161
let char_size = Size::from_bytes(2);
167-
let cmd_alloc = ecx.memory.get_mut(cmd_ptr.alloc_id)?;
168-
let mut cur_ptr = cmd_ptr;
169-
for &c in cmd_utf16.iter() {
170-
cmd_alloc.write_scalar(
171-
&*ecx.tcx,
172-
cur_ptr,
173-
Scalar::from_uint(c, char_size).into(),
174-
char_size,
175-
)?;
176-
cur_ptr = cur_ptr.offset(char_size, &*ecx.tcx)?;
162+
for (idx, &c) in cmd_utf16.iter().enumerate() {
163+
let place = ecx.mplace_field(cmd_place, idx as u64)?;
164+
ecx.write_scalar(Scalar::from_uint(c, char_size), place.into())?;
177165
}
178166
}
179167

180168
args.next().expect_none("start lang item has more arguments than expected");
181169

182170
// Set the last_error to 0
183-
let errno_layout = ecx.layout_of(ecx.tcx.types.u32)?;
171+
let errno_layout = ecx.layout_of(tcx.types.u32)?;
184172
let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Static.into());
185173
ecx.write_scalar(Scalar::from_u32(0), errno_place.into())?;
186174
ecx.machine.last_error = Some(errno_place);
@@ -233,7 +221,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) {
233221
};
234222

235223
let msg = format!("Miri evaluation error: {}", msg);
236-
let mut err = struct_error(ecx.tcx.tcx.at(span), msg.as_str());
224+
let mut err = ecx.tcx.sess.struct_span_err(span, msg.as_str());
237225
let frames = ecx.generate_stacktrace(None);
238226
err.span_label(span, msg);
239227
// We iterate with indices because we need to look at the next frame (the caller).

src/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX};
55
use rustc::mir;
66
use rustc::ty::{
77
self,
8+
List,
89
layout::{self, LayoutOf, Size, TyLayout},
910
};
1011

@@ -75,7 +76,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
7576
/// Get the `Place` for a local
7677
fn local_place(&mut self, local: mir::Local) -> InterpResult<'tcx, PlaceTy<'tcx, Tag>> {
7778
let this = self.eval_context_mut();
78-
let place = mir::Place { base: mir::PlaceBase::Local(local), projection: Box::new([]) };
79+
let place = mir::Place { base: mir::PlaceBase::Local(local), projection: List::empty() };
7980
this.eval_place(&place)
8081
}
8182

src/intptrcast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'mir, 'tcx> GlobalState {
6363
// This never overflows because `int >= glb`
6464
let offset = int - glb;
6565
// If the offset exceeds the size of the allocation, this access is illegal
66-
if offset <= memory.get(alloc_id)?.size.bytes() {
66+
if offset <= memory.get_size_and_align(alloc_id, AllocCheck::MaybeDead)?.0.bytes() {
6767
// This pointer is untagged because it was created from a cast
6868
Pointer::new_with_tag(alloc_id, Size::from_bytes(offset), Tag::Untagged)
6969
} else {

0 commit comments

Comments
 (0)