Merge pull request #2582 from rust-lang-nursery/clippy_aint_no_compiler

Use cargo check instead of cargo rustc
This commit is contained in:
Oliver Schneider 2018-03-28 12:04:18 +02:00 committed by GitHub
commit e34a8553b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View file

@ -186,10 +186,13 @@ pub fn main() {
let clippy_enabled = env::var("CLIPPY_TESTS")
.ok()
.map_or(false, |val| val == "true")
|| orig_args.iter().any(|s| s == "--emit=metadata");
|| orig_args.iter().any(|s| s == "--emit=dep-info,metadata");
if clippy_enabled {
args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]);
if let Ok(extra_args) = env::var("CLIPPY_ARGS") {
args.extend(extra_args.split("__CLIPPY_HACKERY__").filter(|s| !s.is_empty()).map(str::to_owned));
}
}
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);

View file

@ -175,23 +175,22 @@ pub fn main() {
}
}
fn process<I>(old_args: I) -> Result<(), i32>
fn process<I>(mut old_args: I) -> Result<(), i32>
where
I: Iterator<Item = String>,
{
let mut args = vec!["rustc".to_owned()];
let mut args = vec!["check".to_owned()];
let mut found_dashes = false;
for arg in old_args {
for arg in old_args.by_ref() {
found_dashes |= arg == "--";
if found_dashes {
break;
}
args.push(arg);
}
if !found_dashes {
args.push("--".to_owned());
}
args.push("--emit=metadata".to_owned());
args.push("--cfg".to_owned());
args.push(r#"feature="cargo-clippy""#.to_owned());
let clippy_args: String = old_args.map(|arg| format!("{}__CLIPPY_HACKERY__", arg)).collect();
let mut path = std::env::current_exe()
.expect("current executable path invalid")
@ -202,6 +201,7 @@ where
let exit_status = std::process::Command::new("cargo")
.args(&args)
.env("RUSTC_WRAPPER", path)
.env("CLIPPY_ARGS", clippy_args)
.spawn()
.expect("could not run cargo")
.wait()