Skip to content

Commit dd5c9b7

Browse files
committed
lintcheck: Slight improvements to the error reporting
1 parent 2a28ea0 commit dd5c9b7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

clippy_dev/src/lintcheck.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,14 @@ fn filter_clippy_warnings(line: &str) -> bool {
283283

284284
/// Builds clippy inside the repo to make sure we have a clippy executable we can use.
285285
fn build_clippy() {
286-
Command::new("cargo")
286+
let output = Command::new("cargo")
287287
.arg("build")
288288
.output()
289289
.expect("Failed to build clippy!");
290+
if !output.status.success() {
291+
eprintln!("Failed to compile Clippy");
292+
eprintln!("stderr: {}", String::from_utf8_lossy(&output.stderr))
293+
}
290294
}
291295

292296
/// Read a `toml` file and return a list of `CrateSources` that we want to check with clippy
@@ -402,12 +406,14 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> String {
402406

403407
/// lintchecks `main()` function
404408
pub fn run(clap_config: &ArgMatches) {
405-
let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy");
406-
407409
println!("Compiling clippy...");
408410
build_clippy();
409411
println!("Done compiling");
410412

413+
let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy")
414+
.canonicalize()
415+
.expect("failed to canonicalize path to clippy binary");
416+
411417
// assert that clippy is found
412418
assert!(
413419
cargo_clippy_path.is_file(),
@@ -484,5 +490,6 @@ pub fn run(clap_config: &ArgMatches) {
484490
.for_each(|(cratename, msg)| text.push_str(&format!("{}: '{}'", cratename, msg)));
485491

486492
let file = format!("lintcheck-logs/{}_logs.txt", filename);
493+
println!("Writing logs to {}", file);
487494
write(file, text).unwrap();
488495
}

0 commit comments

Comments
 (0)