From: BenoƮt Zugmeyer Date: Mon, 23 May 2016 20:32:51 +0000 (+0200) Subject: Let cargo-clippy exit with a code > 0 if some error occured X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7a9dac4e1cd0a44d69f203ed4c2e09cf6f464977;p=rust.git Let cargo-clippy exit with a code > 0 if some error occured --- diff --git a/src/lib.rs b/src/lib.rs index 888abbc92c5..bcf8f86b10a 100644 --- a/src/lib.rs +++ b/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 = 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); + } + } } }