fix build

This commit is contained in:
Ralf Jung 2019-02-08 20:07:49 +01:00
parent 0802b3a108
commit e400b42c21
2 changed files with 12 additions and 5 deletions

View file

@ -4,11 +4,13 @@ extern crate rustc;
extern crate rustc_driver;
extern crate test;
use self::miri::eval_main;
use self::rustc_driver::{driver, Compilation};
use rustc_driver::{driver, Compilation};
use rustc::hir::def_id::LOCAL_CRATE;
use std::cell::RefCell;
use std::rc::Rc;
use miri::{MiriConfig, eval_main};
use crate::test::Bencher;
pub struct MiriCompilerCalls<'a>(Rc<RefCell<&'a mut Bencher>>);
@ -50,7 +52,8 @@ pub fn run(filename: &str, bencher: &mut Bencher) {
);
bencher.borrow_mut().iter(|| {
eval_main(tcx, entry_def_id, false);
let config = MiriConfig { validate: true, args: vec![] };
eval_main(tcx, entry_def_id, config);
});
state.session.abort_if_errors();

View file

@ -25,6 +25,8 @@ use rustc::ty::TyCtxt;
use syntax::ast;
use rustc::hir::def_id::LOCAL_CRATE;
use miri::MiriConfig;
struct MiriCompilerCalls {
default: Box<RustcDefaultCalls>,
/// whether we are building for the host
@ -94,9 +96,10 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'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.name() == "test") {
let config = MiriConfig { validate: true, args: vec![] };
let did = self.0.hir().body_owner_def_id(body_id);
println!("running test: {}", self.0.def_path_debug_str(did));
miri::eval_main(self.0, did, /*validate*/true);
miri::eval_main(self.0, did, config);
self.1.session.abort_if_errors();
}
}
@ -106,7 +109,8 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) {
}
state.hir_crate.unwrap().visit_all_item_likes(&mut Visitor(tcx, state));
} else if let Some((entry_def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
miri::eval_main(tcx, entry_def_id, /*validate*/true);
let config = MiriConfig { validate: true, args: vec![] };
miri::eval_main(tcx, entry_def_id, config);
state.session.abort_if_errors();
} else {