don't abort after successfully linting a target

This commit is contained in:
Oliver Schneider 2016-06-06 11:28:09 +02:00
parent a3f7fea36c
commit a81181b758
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46

View File

@ -128,9 +128,13 @@ pub fn main() {
let args = std::env::args().skip(2);
if let Some(first) = target.kind.get(0) {
if target.kind.len() > 1 || first.ends_with("lib") {
process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root);
if let Err(code) = process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root) {
std::process::exit(code);
}
} else if first == "bin" {
process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root);
if let Err(code) = process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root) {
std::process::exit(code);
}
}
} else {
panic!("badly formatted cargo metadata: target::kind is an empty array");
@ -152,7 +156,7 @@ pub fn main() {
}
}
fn process<P, I>(old_args: I, dep_path: P, sysroot: &str)
fn process<P, I>(old_args: I, dep_path: P, sysroot: &str) -> Result<(), i32>
where P: AsRef<Path>, I: Iterator<Item=String> {
let mut args = vec!["rustc".to_owned()];
@ -178,7 +182,10 @@ fn process<P, I>(old_args: I, dep_path: P, sysroot: &str)
.spawn().expect("could not run cargo")
.wait().expect("failed to wait for cargo?");
if let Some(code) = exit_status.code() {
std::process::exit(code);
if exit_status.success() {
Ok(())
} else {
use std::os::unix::process::ExitStatusExt;
Err(exit_status.code().or(exit_status.signal()).unwrap_or(-1))
}
}