Use rustc_driver::run (fixes #2303)
This internally uses monitor() which catches panics and stuff
This commit is contained in:
parent
a2fdfc05d7
commit
3c4f5bfae2
1 changed files with 38 additions and 41 deletions
|
@ -12,7 +12,7 @@ extern crate rustc_plugin;
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
|
|
||||||
use rustc_driver::{driver, Compilation, CompilerCalls, RustcDefaultCalls};
|
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 rustc::session::config::{ErrorOutputType, Input};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
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");
|
.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.
|
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
|
||||||
// We're invoking the compiler programmatically, so we ignore this/
|
// We're invoking the compiler programmatically, so we ignore this/
|
||||||
let mut orig_args: Vec<String> = env::args().collect();
|
let mut orig_args: Vec<String> = env::args().collect();
|
||||||
|
@ -191,9 +190,7 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);
|
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);
|
||||||
let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None);
|
rustc_driver::run(move || {
|
||||||
if let Err(CompileIncomplete::Errored(_)) = result {
|
rustc_driver::run_compiler(&args, &mut ccc, None, None)
|
||||||
std::process::exit(1);
|
});
|
||||||
}
|
|
||||||
}).expect("rustc_thread failed");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue