Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cargo check instead of cargo rustc #2582

Merged
merged 1 commit into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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