Use rustc_driver::run (fixes #2303)

This internally uses monitor() which catches panics and stuff
This commit is contained in:
Manish Goregaokar 2017-12-28 17:34:11 +05:30 committed by Oliver Schneider
parent a2fdfc05d7
commit 3c4f5bfae2
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9

View file

@ -12,7 +12,7 @@ extern crate rustc_plugin;
extern crate syntax;
use rustc_driver::{driver, Compilation, CompilerCalls, RustcDefaultCalls};
use rustc::session::{config, CompileIncomplete, Session};
use rustc::session::{config, Session};
use rustc::session::config::{ErrorOutputType, Input};
use std::path::PathBuf;
use std::process::Command;
@ -153,7 +153,6 @@ pub fn main() {
})
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust");
rustc_driver::in_rustc_thread(|| {
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
// We're invoking the compiler programmatically, so we ignore this/
let mut orig_args: Vec<String> = env::args().collect();
@ -191,9 +190,7 @@ pub fn main() {
}
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);
let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None);
if let Err(CompileIncomplete::Errored(_)) = result {
std::process::exit(1);
}
}).expect("rustc_thread failed");
rustc_driver::run(move || {
rustc_driver::run_compiler(&args, &mut ccc, None, None)
});
}