Skip to content

Commit e338604

Browse files
committed
lintcheck: uses consts for clippy driver and cargo clippy paths
1 parent 2d9932d commit e338604

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

clippy_dev/src/lintcheck.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use rayon::prelude::*;
1919
use serde::{Deserialize, Serialize};
2020
use serde_json::Value;
2121

22+
const CLIPPY_DRIVER_PATH: &str = "target/debug/clippy-driver";
23+
const CARGO_CLIPPY_PATH: &str = "target/debug/cargo-clippy";
24+
2225
/// List of sources to check, loaded from a .toml file
2326
#[derive(Debug, Serialize, Deserialize)]
2427
struct SourceList {
@@ -317,6 +320,9 @@ impl LintcheckConfig {
317320
let filename: PathBuf = sources_toml_path.file_stem().unwrap().into();
318321
let lintcheck_results_path = PathBuf::from(format!("lintcheck-logs/{}_logs.txt", filename.display()));
319322

323+
// look at the --threads arg, if 0 is passed, ask rayon rayon how many threads it would spawn and
324+
// use half of that for the physical core count
325+
// by default use a single thread
320326
let max_jobs = match clap_config.value_of("threads") {
321327
Some(threads) => {
322328
let threads: usize = threads
@@ -492,14 +498,12 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> (String, HashMap<&String,
492498
/// clippy binary, if this is true, we should clean the lintchec shared target directory and recheck
493499
fn lintcheck_needs_rerun(toml_path: &PathBuf) -> bool {
494500
let clippy_modified: std::time::SystemTime = {
495-
let mut times = ["target/debug/clippy-driver", "target/debug/cargo-clippy"]
496-
.iter()
497-
.map(|p| {
498-
std::fs::metadata(p)
499-
.expect("failed to get metadata of file")
500-
.modified()
501-
.expect("failed to get modification date")
502-
});
501+
let mut times = [CLIPPY_DRIVER_PATH, CARGO_CLIPPY_PATH].iter().map(|p| {
502+
std::fs::metadata(p)
503+
.expect("failed to get metadata of file")
504+
.modified()
505+
.expect("failed to get modification date")
506+
});
503507
// the oldest modification of either of the binaries
504508
std::cmp::min(times.next().unwrap(), times.next().unwrap())
505509
};
@@ -539,7 +543,7 @@ pub fn run(clap_config: &ArgMatches) {
539543
}
540544
}
541545

542-
let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy")
546+
let cargo_clippy_path: PathBuf = PathBuf::from(CARGO_CLIPPY_PATH)
543547
.canonicalize()
544548
.expect("failed to canonicalize path to clippy binary");
545549

@@ -550,7 +554,7 @@ pub fn run(clap_config: &ArgMatches) {
550554
cargo_clippy_path.display()
551555
);
552556

553-
let clippy_ver = std::process::Command::new("target/debug/cargo-clippy")
557+
let clippy_ver = std::process::Command::new(CARGO_CLIPPY_PATH)
554558
.arg("--version")
555559
.output()
556560
.map(|o| String::from_utf8_lossy(&o.stdout).into_owned())

0 commit comments

Comments
 (0)