Skip to content

Commit 1f8aa8d

Browse files
authored
Merge pull request rust-lang#163 from solson/rustup
Rustup to rustc 1.19.0-nightly (2d4ed8e 2017-05-03)
2 parents f8c8813 + 5f67ba7 commit 1f8aa8d

File tree

8 files changed

+32
-75
lines changed

8 files changed

+32
-75
lines changed

benches/helpers/miri_helper.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate rustc;
44
extern crate rustc_driver;
55
extern crate test;
66

7-
use self::miri::{eval_main, run_mir_passes};
7+
use self::miri::eval_main;
88
use self::rustc::session::Session;
99
use self::rustc_driver::{driver, CompilerCalls, Compilation};
1010
use std::cell::RefCell;
@@ -55,7 +55,6 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
5555
.expect("no main or start function found");
5656
let entry_def_id = tcx.map.local_def_id(entry_node_id);
5757

58-
run_mir_passes(tcx);
5958
let memory_size = 100*1024*1024; // 100MB
6059
let step_limit = 1000_000;
6160
let stack_limit = 100;

src/bin/miri.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) {
7474
state.session.abort_if_errors();
7575

7676
let tcx = state.tcx.unwrap();
77-
miri::run_mir_passes(tcx);
7877
let limits = resource_limits_from_attributes(state);
7978

8079
if std::env::args().any(|arg| arg == "--test") {
@@ -94,15 +93,13 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) {
9493
fn visit_impl_item(&mut self, _impl_item: &'hir hir::ImplItem) {}
9594
}
9695
state.hir_crate.unwrap().visit_all_item_likes(&mut Visitor(limits, tcx, state));
97-
} else {
98-
if let Some((entry_node_id, _)) = *state.session.entry_fn.borrow() {
99-
let entry_def_id = tcx.hir.local_def_id(entry_node_id);
100-
miri::eval_main(tcx, entry_def_id, limits);
96+
} else if let Some((entry_node_id, _)) = *state.session.entry_fn.borrow() {
97+
let entry_def_id = tcx.hir.local_def_id(entry_node_id);
98+
miri::eval_main(tcx, entry_def_id, limits);
10199

102-
state.session.abort_if_errors();
103-
} else {
104-
println!("no main function found, assuming auxiliary build");
105-
}
100+
state.session.abort_if_errors();
101+
} else {
102+
println!("no main function found, assuming auxiliary build");
106103
}
107104
}
108105

src/eval_context.rs

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::cell::Ref;
21
use std::collections::HashMap;
32
use std::fmt::Write;
43

@@ -24,8 +23,6 @@ use memory::{Memory, Pointer};
2423
use operator;
2524
use value::{PrimVal, PrimValKind, Value};
2625

27-
pub type MirRef<'tcx> = Ref<'tcx, mir::Mir<'tcx>>;
28-
2926
pub struct EvalContext<'a, 'tcx: 'a> {
3027
/// The results of the type checker, from rustc.
3128
pub(crate) tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -48,7 +45,7 @@ pub struct EvalContext<'a, 'tcx: 'a> {
4845
pub(crate) steps_remaining: u64,
4946

5047
/// Drop glue for arrays and slices
51-
pub(crate) seq_drop_glue: MirRef<'tcx>,
48+
pub(crate) seq_drop_glue: &'tcx mir::Mir<'tcx>,
5249
}
5350

5451
/// A stack frame.
@@ -58,7 +55,7 @@ pub struct Frame<'tcx> {
5855
////////////////////////////////////////////////////////////////////////////////
5956

6057
/// The MIR for the function called on this frame.
61-
pub mir: MirRef<'tcx>,
58+
pub mir: &'tcx mir::Mir<'tcx>,
6259

6360
/// The def_id and substs of the current function
6461
pub instance: ty::Instance<'tcx>,
@@ -302,16 +299,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
302299
DUMMY_SP,
303300
);
304301
let seq_drop_glue = tcx.alloc_mir(seq_drop_glue);
305-
// Perma-borrow MIR from shims to prevent mutation.
306-
::std::mem::forget(seq_drop_glue.borrow());
307302
EvalContext {
308303
tcx,
309304
memory: Memory::new(&tcx.data_layout, limits.memory_size),
310305
globals: HashMap::new(),
311306
stack: Vec::new(),
312307
stack_limit: limits.stack_limit,
313308
steps_remaining: limits.step_limit,
314-
seq_drop_glue: seq_drop_glue.borrow(),
309+
seq_drop_glue: seq_drop_glue,
315310
}
316311
}
317312

@@ -385,10 +380,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
385380
ty.is_sized(self.tcx, &self.tcx.empty_parameter_environment(), DUMMY_SP)
386381
}
387382

388-
pub fn load_mir(&self, instance: ty::InstanceDef<'tcx>) -> EvalResult<'tcx, MirRef<'tcx>> {
383+
pub fn load_mir(&self, instance: ty::InstanceDef<'tcx>) -> EvalResult<'tcx, &'tcx mir::Mir<'tcx>> {
389384
trace!("load mir {:?}", instance);
390385
match instance {
391-
ty::InstanceDef::Item(def_id) => self.tcx.maybe_item_mir(def_id).ok_or_else(|| EvalError::NoMirFor(self.tcx.item_path_str(def_id))),
386+
ty::InstanceDef::Item(def_id) => self.tcx.maybe_optimized_mir(def_id).ok_or_else(|| EvalError::NoMirFor(self.tcx.item_path_str(def_id))),
392387
_ => Ok(self.tcx.instance_mir(instance)),
393388
}
394389
}
@@ -450,7 +445,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
450445
&mut self,
451446
instance: ty::Instance<'tcx>,
452447
span: codemap::Span,
453-
mir: MirRef<'tcx>,
448+
mir: &'tcx mir::Mir<'tcx>,
454449
return_lvalue: Lvalue<'tcx>,
455450
return_to_block: StackPopCleanup,
456451
) -> EvalResult<'tcx> {
@@ -1028,7 +1023,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
10281023
}
10291024

10301025
pub(super) fn operand_ty(&self, operand: &mir::Operand<'tcx>) -> Ty<'tcx> {
1031-
self.monomorphize(operand.ty(&self.mir(), self.tcx), self.substs())
1026+
self.monomorphize(operand.ty(self.mir(), self.tcx), self.substs())
10321027
}
10331028

10341029
fn copy(&mut self, src: Pointer, dest: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx> {
@@ -1445,8 +1440,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
14451440
self.stack.last_mut().expect("no call frames exist")
14461441
}
14471442

1448-
pub(super) fn mir(&self) -> MirRef<'tcx> {
1449-
Ref::clone(&self.frame().mir)
1443+
pub(super) fn mir(&self) -> &'tcx mir::Mir<'tcx> {
1444+
self.frame().mir
14501445
}
14511446

14521447
pub(super) fn substs(&self) -> &'tcx Substs<'tcx> {
@@ -1734,32 +1729,6 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
17341729
err.emit();
17351730
}
17361731

1737-
pub fn run_mir_passes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
1738-
let mut passes = ::rustc::mir::transform::Passes::new();
1739-
passes.push_hook(Box::new(::rustc_mir::transform::dump_mir::DumpMir));
1740-
passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads));
1741-
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("no-landing-pads")));
1742-
1743-
// From here on out, regions are gone.
1744-
passes.push_pass(Box::new(::rustc_mir::transform::erase_regions::EraseRegions));
1745-
1746-
passes.push_pass(Box::new(::rustc_mir::transform::add_call_guards::AddCallGuards));
1747-
passes.push_pass(Box::new(::rustc_borrowck::ElaborateDrops));
1748-
passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads));
1749-
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("elaborate-drops")));
1750-
1751-
// No lifetime analysis based on borrowing can be done from here on out.
1752-
passes.push_pass(Box::new(::rustc_mir::transform::instcombine::InstCombine::new()));
1753-
passes.push_pass(Box::new(::rustc_mir::transform::deaggregator::Deaggregator));
1754-
passes.push_pass(Box::new(::rustc_mir::transform::copy_prop::CopyPropagation));
1755-
1756-
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyLocals));
1757-
passes.push_pass(Box::new(::rustc_mir::transform::add_call_guards::AddCallGuards));
1758-
passes.push_pass(Box::new(::rustc_mir::transform::dump_mir::Marker("PreMiri")));
1759-
1760-
passes.run_passes(tcx);
1761-
}
1762-
17631732
// TODO(solson): Upstream these methods into rustc::ty::layout.
17641733

17651734
pub(super) trait IntegerExt {

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ extern crate log;
99
extern crate log_settings;
1010
#[macro_use]
1111
extern crate rustc;
12-
extern crate rustc_borrowck;
1312
extern crate rustc_const_math;
1413
extern crate rustc_data_structures;
15-
extern crate rustc_mir;
1614
extern crate syntax;
1715

1816
// From crates.io.
@@ -40,7 +38,6 @@ pub use eval_context::{
4038
ResourceLimits,
4139
StackPopCleanup,
4240
eval_main,
43-
run_mir_passes,
4441
};
4542

4643
pub use lvalue::{

src/lvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
399399
}
400400

401401
pub(super) fn lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> {
402-
self.monomorphize(lvalue.ty(&self.mir(), self.tcx).to_ty(self.tcx), self.substs())
402+
self.monomorphize(lvalue.ty(self.mir(), self.tcx).to_ty(self.tcx), self.substs())
403403
}
404404
}

src/step.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
//!
33
//! The main entry point is the `step` method.
44
5-
use std::cell::Ref;
6-
75
use rustc::hir::def_id::DefId;
86
use rustc::hir;
97
use rustc::mir::visit::{Visitor, LvalueContext};
@@ -12,7 +10,7 @@ use rustc::ty::layout::Layout;
1210
use rustc::ty::{subst, self};
1311

1412
use error::{EvalResult, EvalError};
15-
use eval_context::{EvalContext, StackPopCleanup, MirRef};
13+
use eval_context::{EvalContext, StackPopCleanup};
1614
use lvalue::{Global, GlobalId, Lvalue};
1715
use value::{Value, PrimVal};
1816
use syntax::codemap::Span;
@@ -47,7 +45,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
4745
span: stmt.source_info.span,
4846
instance: self.frame().instance,
4947
ecx: self,
50-
mir: Ref::clone(&mir),
48+
mir,
5149
new_constants: &mut new,
5250
}.visit_statement(block, stmt, mir::Location { block, statement_index: stmt_id });
5351
if new? == 0 {
@@ -64,7 +62,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
6462
span: terminator.source_info.span,
6563
instance: self.frame().instance,
6664
ecx: self,
67-
mir: Ref::clone(&mir),
65+
mir,
6866
new_constants: &mut new,
6967
}.visit_terminator(block, terminator, mir::Location { block, statement_index: stmt_id });
7068
if new? == 0 {
@@ -142,7 +140,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
142140
struct ConstantExtractor<'a, 'b: 'a, 'tcx: 'b> {
143141
span: Span,
144142
ecx: &'a mut EvalContext<'b, 'tcx>,
145-
mir: MirRef<'tcx>,
143+
mir: &'tcx mir::Mir<'tcx>,
146144
instance: ty::Instance<'tcx>,
147145
new_constants: &'a mut EvalResult<'tcx, u64>,
148146
}
@@ -209,8 +207,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
209207
if self.ecx.globals.contains_key(&cid) {
210208
return;
211209
}
212-
let mir = Ref::clone(&self.mir);
213-
let mir = Ref::map(mir, |mir| &mir.promoted[index]);
210+
let mir = &self.mir.promoted[index];
214211
self.try(|this| {
215212
let ty = this.ecx.monomorphize(mir.return_ty, this.instance.substs);
216213
this.ecx.globals.insert(cid, Global::uninitialized(ty));

src/terminator/drop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
5353
_ => bug!("expected thin ptr, got {:?}", arg),
5454
};
5555
arg = Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n as u128));
56-
::eval_context::MirRef::clone(&self.seq_drop_glue)
56+
self.seq_drop_glue
5757
},
5858
ty::TySlice(elem) => {
5959
instance.substs = self.tcx.mk_substs([
6060
Kind::from(elem),
6161
].iter().cloned());
62-
::eval_context::MirRef::clone(&self.seq_drop_glue)
62+
self.seq_drop_glue
6363
},
6464
_ => self.load_mir(instance.def)?,
6565
};

tests/compiletest.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::Write;
55

66
fn compile_fail(sysroot: &Path) {
77
let flags = format!("--sysroot {} -Dwarnings", sysroot.to_str().expect("non utf8 path"));
8-
for_all_targets(&sysroot, |target| {
8+
for_all_targets(sysroot, |target| {
99
let mut config = compiletest::default_config();
1010
config.host_rustcflags = Some(flags.clone());
1111
config.mode = "compile-fail".parse().expect("Invalid mode");
@@ -79,8 +79,8 @@ fn compile_test() {
7979
.expect("rustc not found for -vV")
8080
.stdout;
8181
let host = std::str::from_utf8(&host).expect("sysroot is not utf8");
82-
let host = host.split("\nhost: ").skip(1).next().expect("no host: part in rustc -vV");
83-
let host = host.split("\n").next().expect("no \n after host");
82+
let host = host.split("\nhost: ").nth(1).expect("no host: part in rustc -vV");
83+
let host = host.split('\n').next().expect("no \n after host");
8484

8585
if let Ok(path) = std::env::var("MIRI_RUSTC_TEST") {
8686
let mut mir_not_found = Vec::new();
@@ -148,10 +148,8 @@ fn compile_test() {
148148
abi.push(text[abi_s.len()..end].to_string());
149149
} else if text.starts_with(limit_s) {
150150
limits.push(text[limit_s.len()..end].to_string());
151-
} else {
152-
if text.find("aborting").is_none() {
153-
failed.push(text[..end].to_string());
154-
}
151+
} else if text.find("aborting").is_none() {
152+
failed.push(text[..end].to_string());
155153
}
156154
}
157155
writeln!(stderr.lock(), "FAILED with exit code {:?}", output.status.code()).unwrap();
@@ -196,10 +194,10 @@ fn compile_test() {
196194
panic!("ran miri on rustc test suite. Test failing for convenience");
197195
} else {
198196
run_pass();
199-
for_all_targets(&sysroot, |target| {
197+
for_all_targets(sysroot, |target| {
200198
miri_pass("tests/run-pass", &target, host);
201199
});
202-
compile_fail(&sysroot);
200+
compile_fail(sysroot);
203201
}
204202
}
205203

@@ -218,7 +216,7 @@ fn vec_to_hist<T: PartialEq + Ord>(mut v: Vec<T>) -> Vec<(usize, T)> {
218216
let mut current = v.next();
219217
'outer: while let Some(current_val) = current {
220218
let mut n = 1;
221-
while let Some(next) = v.next() {
219+
for next in &mut v {
222220
if next == current_val {
223221
n += 1;
224222
} else {

0 commit comments

Comments
 (0)