Skip to content

Commit

Permalink
Merge pull request #2582 from rust-lang-nursery/clippy_aint_no_compiler
Browse files Browse the repository at this point in the history
Use cargo check instead of cargo rustc
  • Loading branch information
oli-obk authored Mar 28, 2018
2 parents 9b10c4b + 66a98d2 commit e34a855
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down

0 comments on commit e34a855

Please sign in to comment.