Skip to content

Commit e34a855

Browse files
authored
Merge pull request #2582 from rust-lang-nursery/clippy_aint_no_compiler
Use cargo check instead of cargo rustc
2 parents 9b10c4b + 66a98d2 commit e34a855

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/driver.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@ pub fn main() {
186186
let clippy_enabled = env::var("CLIPPY_TESTS")
187187
.ok()
188188
.map_or(false, |val| val == "true")
189-
|| orig_args.iter().any(|s| s == "--emit=metadata");
189+
|| orig_args.iter().any(|s| s == "--emit=dep-info,metadata");
190190

191191
if clippy_enabled {
192192
args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]);
193+
if let Ok(extra_args) = env::var("CLIPPY_ARGS") {
194+
args.extend(extra_args.split("__CLIPPY_HACKERY__").filter(|s| !s.is_empty()).map(str::to_owned));
195+
}
193196
}
194197

195198
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);

src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,23 +175,22 @@ pub fn main() {
175175
}
176176
}
177177

178-
fn process<I>(old_args: I) -> Result<(), i32>
178+
fn process<I>(mut old_args: I) -> Result<(), i32>
179179
where
180180
I: Iterator<Item = String>,
181181
{
182-
let mut args = vec!["rustc".to_owned()];
182+
let mut args = vec!["check".to_owned()];
183183

184184
let mut found_dashes = false;
185-
for arg in old_args {
185+
for arg in old_args.by_ref() {
186186
found_dashes |= arg == "--";
187+
if found_dashes {
188+
break;
189+
}
187190
args.push(arg);
188191
}
189-
if !found_dashes {
190-
args.push("--".to_owned());
191-
}
192-
args.push("--emit=metadata".to_owned());
193-
args.push("--cfg".to_owned());
194-
args.push(r#"feature="cargo-clippy""#.to_owned());
192+
193+
let clippy_args: String = old_args.map(|arg| format!("{}__CLIPPY_HACKERY__", arg)).collect();
195194

196195
let mut path = std::env::current_exe()
197196
.expect("current executable path invalid")
@@ -202,6 +201,7 @@ where
202201
let exit_status = std::process::Command::new("cargo")
203202
.args(&args)
204203
.env("RUSTC_WRAPPER", path)
204+
.env("CLIPPY_ARGS", clippy_args)
205205
.spawn()
206206
.expect("could not run cargo")
207207
.wait()

0 commit comments

Comments
 (0)