Skip to content

Commit

Permalink
Rustup (#723)
Browse files Browse the repository at this point in the history
Rustup
  • Loading branch information
RalfJung committed May 15, 2019
2 parents 2602569 + 7a5a030 commit 3d43a0b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7c71bc3208031b1307573de45a3b3e18fa45787a
372be4f360ce42b1a10126a711189796f8440ab4
4 changes: 2 additions & 2 deletions src/bin/miri-rustc-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct MiriCompilerCalls {
impl rustc_driver::Callbacks for MiriCompilerCalls {
fn after_parsing(&mut self, compiler: &interface::Compiler) -> bool {
let attr = (
String::from("miri"),
syntax::symbol::Symbol::intern("miri"),
syntax::feature_gate::AttributeType::Whitelisted,
);
compiler.session().plugin_attributes.borrow_mut().push(attr);
Expand All @@ -47,7 +47,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
impl<'a, 'tcx: 'a, 'hir> itemlikevisit::ItemLikeVisitor<'hir> for Visitor<'a, 'tcx> {
fn visit_item(&mut self, i: &'hir hir::Item) {
if let hir::ItemKind::Fn(.., body_id) = i.node {
if i.attrs.iter().any(|attr| attr.check_name("test")) {
if i.attrs.iter().any(|attr| attr.check_name(syntax::symbol::sym::test)) {
let config = MiriConfig { validate: true, args: vec![], seed: None };
let did = self.0.hir().body_owner_def_id(body_id);
println!("running test: {}", self.0.def_path_debug_str(did));
Expand Down
14 changes: 7 additions & 7 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct MiriCompilerCalls {
impl rustc_driver::Callbacks for MiriCompilerCalls {
fn after_parsing(&mut self, compiler: &interface::Compiler) -> bool {
let attr = (
String::from("miri"),
syntax::symbol::Symbol::intern("miri"),
syntax::feature_gate::AttributeType::Whitelisted,
);
compiler.session().plugin_attributes.borrow_mut().push(attr);
Expand Down Expand Up @@ -66,26 +66,26 @@ fn init_early_loggers() {
// If it is not set, we avoid initializing now so that we can initialize
// later with our custom settings, and *not* log anything for what happens before
// `miri` gets started.
if env::var("RUST_LOG").is_ok() {
if env::var("RUSTC_LOG").is_ok() {
rustc_driver::init_rustc_env_logger();
}
}

fn init_late_loggers() {
// We initialize loggers right before we start evaluation. We overwrite the `RUST_LOG`
// We initialize loggers right before we start evaluation. We overwrite the `RUSTC_LOG`
// env var if it is not set, control it based on `MIRI_LOG`.
if let Ok(var) = env::var("MIRI_LOG") {
if env::var("RUST_LOG").is_err() {
if env::var("RUSTC_LOG").is_err() {
// We try to be a bit clever here: if `MIRI_LOG` is just a single level
// used for everything, we only apply it to the parts of rustc that are
// CTFE-related. Otherwise, we use it verbatim for `RUST_LOG`.
// CTFE-related. Otherwise, we use it verbatim for `RUSTC_LOG`.
// This way, if you set `MIRI_LOG=trace`, you get only the right parts of
// rustc traced, but you can also do `MIRI_LOG=miri=trace,rustc_mir::interpret=debug`.
if log::Level::from_str(&var).is_ok() {
env::set_var("RUST_LOG",
env::set_var("RUSTC_LOG",
&format!("rustc::mir::interpret={0},rustc_mir::interpret={0}", var));
} else {
env::set_var("RUST_LOG", &var);
env::set_var("RUSTC_LOG", &var);
}
rustc_driver::init_rustc_env_logger();
}
Expand Down
3 changes: 2 additions & 1 deletion src/fn_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rustc::ty::layout::{Align, LayoutOf, Size};
use rustc::hir::def_id::DefId;
use rustc::mir;
use syntax::attr;
use syntax::symbol::sym;

use rand::RngCore;

Expand Down Expand Up @@ -141,7 +142,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
) -> EvalResult<'tcx> {
let this = self.eval_context_mut();
let attrs = this.tcx.get_attrs(def_id);
let link_name = match attr::first_attr_value_str_by_name(&attrs, "link_name") {
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
Some(name) => name.as_str(),
None => this.tcx.item_name(def_id).as_str(),
};
Expand Down
8 changes: 4 additions & 4 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
this.tcx
.crates()
.iter()
.find(|&&krate| this.tcx.original_crate_name(krate) == path[0])
.find(|&&krate| this.tcx.original_crate_name(krate).as_str() == path[0])
.and_then(|krate| {
let krate = DefId {
krate: *krate,
Expand All @@ -25,12 +25,12 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'

while let Some(segment) = path_it.next() {
for item in mem::replace(&mut items, Default::default()).iter() {
if item.ident.name == *segment {
if item.ident.name.as_str() == *segment {
if path_it.peek().is_none() {
return Some(ty::Instance::mono(this.tcx.tcx, item.def.def_id()));
return Some(ty::Instance::mono(this.tcx.tcx, item.res.def_id()));
}

items = this.tcx.item_children(item.def.def_id());
items = this.tcx.item_children(item.res.def_id());
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use rustc_mir::interpret::*;
pub use rustc_mir::interpret::{self, AllocMap, PlaceTy};
use syntax::attr;
use syntax::source_map::DUMMY_SP;
use syntax::symbol::sym;

pub use crate::fn_call::EvalContextExt as MissingFnsEvalContextExt;
pub use crate::operator::EvalContextExt as OperatorEvalContextExt;
Expand Down Expand Up @@ -478,7 +479,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
memory_extra: &Self::MemoryExtra,
) -> EvalResult<'tcx, Cow<'tcx, Allocation<Tag, Self::AllocExtra>>> {
let attrs = tcx.get_attrs(def_id);
let link_name = match attr::first_attr_value_str_by_name(&attrs, "link_name") {
let link_name = match attr::first_attr_value_str_by_name(&attrs, sym::link_name) {
Some(name) => name.as_str(),
None => tcx.item_name(def_id).as_str(),
};
Expand Down
8 changes: 3 additions & 5 deletions tests/run-pass/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ fn test_map<S: BuildHasher>(mut map: HashMap<i32, i32, S>) {
}

fn main() {
if cfg!(target_os = "macos") { // TODO: Implement random number generation on OS X.
if cfg!(target_os = "macos") { // TODO: Implement libstd HashMap seeding for macOS (https://github.com/rust-lang/miri/issues/686).
// Until then, use a deterministic map.
let map : HashMap<i32, i32, BuildHasherDefault<collections::hash_map::DefaultHasher>> = HashMap::default();
test_map(map);
test_map::<BuildHasherDefault<collections::hash_map::DefaultHasher>>(HashMap::default());
} else {
let map: HashMap<i32, i32> = HashMap::default();
test_map(map);
test_map(HashMap::new());
}
}

0 comments on commit 3d43a0b

Please sign in to comment.