From 7a9dac4e1cd0a44d69f203ed4c2e09cf6f464977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Zugmeyer?= Date: Mon, 23 May 2016 22:32:51 +0200 Subject: [PATCH] Let cargo-clippy exit with a code > 0 if some error occured --- src/lib.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 888abbc92..bcf8f86b1 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); + } + } } }