1 #![feature(rustc_private, custom_attribute)]
2 #![allow(unused_attributes)]
7 extern crate rustc_driver;
8 extern crate env_logger;
9 extern crate log_settings;
12 use miri::interpreter;
13 use rustc::session::Session;
14 use rustc_driver::{driver, CompilerCalls};
16 struct MiriCompilerCalls;
18 impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
23 ) -> driver::CompileController<'a> {
24 let mut control = driver::CompileController::basic();
26 control.after_analysis.callback = Box::new(|state| {
27 state.session.abort_if_errors();
28 interpreter::interpret_start_points(state.tcx.unwrap(), state.mir_map.unwrap());
38 let args: Vec<String> = std::env::args().collect();
39 rustc_driver::run_compiler(&args, &mut MiriCompilerCalls);
44 let format = |record: &log::LogRecord| {
45 // prepend spaces to indent the final string
46 let indentation = log_settings::settings().indentation;
47 let spaces = " | | | | | | | | ";
48 let indentation = &spaces[..std::cmp::min(indentation, spaces.len())];
49 format!("{}:{}|{} {}", record.level(), record.location().module_path(), indentation, record.args())
52 let mut builder = env_logger::LogBuilder::new();
53 builder.format(format).filter(None, log::LogLevelFilter::Info);
55 if std::env::var("RUST_LOG").is_ok() {
56 builder.parse(&std::env::var("RUST_LOG").unwrap());
59 builder.init().unwrap();