Skip to content

Commit 7a9dac4

Browse files
Let cargo-clippy exit with a code > 0 if some error occured
1 parent fec701b commit 7a9dac4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,28 @@ pub fn main() {
122122
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
123123
let args = wrap_args(std::env::args().skip(2), dep_path, sys_root);
124124
let path = std::env::current_exe().expect("current executable path invalid");
125-
std::process::Command::new("cargo")
125+
let exit_status = std::process::Command::new("cargo")
126126
.args(&args)
127127
.env("RUSTC", path)
128128
.spawn().expect("could not run cargo")
129129
.wait().expect("failed to wait for cargo?");
130+
131+
if let Some(code) = exit_status.code() {
132+
std::process::exit(code);
133+
}
130134
} else {
131135
let args: Vec<String> = if env::args().any(|s| s == "--sysroot") {
132136
env::args().collect()
133137
} else {
134138
env::args().chain(Some("--sysroot".to_owned())).chain(Some(sys_root)).collect()
135139
};
136-
rustc_driver::run_compiler(&args, &mut ClippyCompilerCalls::new());
140+
let (result, _) = rustc_driver::run_compiler(&args, &mut ClippyCompilerCalls::new());
141+
142+
if let Err(err_count) = result {
143+
if err_count > 0 {
144+
std::process::exit(1);
145+
}
146+
}
137147
}
138148
}
139149

0 commit comments

Comments
 (0)