mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Merge pull request #948 from BenoitZugmeyer/cargo-clippy-exit-code
Let cargo-clippy exit with a code > 0 if some error occured
This commit is contained in:
commit
84098f56b6
1 changed files with 12 additions and 2 deletions
14
src/lib.rs
14
src/lib.rs
|
@ -122,18 +122,28 @@ pub fn main() {
|
|||
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
|
||||
let args = wrap_args(std::env::args().skip(2), dep_path, sys_root);
|
||||
let path = std::env::current_exe().expect("current executable path invalid");
|
||||
std::process::Command::new("cargo")
|
||||
let exit_status = std::process::Command::new("cargo")
|
||||
.args(&args)
|
||||
.env("RUSTC", path)
|
||||
.spawn().expect("could not run cargo")
|
||||
.wait().expect("failed to wait for cargo?");
|
||||
|
||||
if let Some(code) = exit_status.code() {
|
||||
std::process::exit(code);
|
||||
}
|
||||
} else {
|
||||
let args: Vec<String> = if env::args().any(|s| s == "--sysroot") {
|
||||
env::args().collect()
|
||||
} else {
|
||||
env::args().chain(Some("--sysroot".to_owned())).chain(Some(sys_root)).collect()
|
||||
};
|
||||
rustc_driver::run_compiler(&args, &mut ClippyCompilerCalls::new());
|
||||
let (result, _) = rustc_driver::run_compiler(&args, &mut ClippyCompilerCalls::new());
|
||||
|
||||
if let Err(err_count) = result {
|
||||
if err_count > 0 {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue