@@ -19,6 +19,9 @@ use rayon::prelude::*;
19
19
use serde:: { Deserialize , Serialize } ;
20
20
use serde_json:: Value ;
21
21
22
+ const CLIPPY_DRIVER_PATH : & str = "target/debug/clippy-driver" ;
23
+ const CARGO_CLIPPY_PATH : & str = "target/debug/cargo-clippy" ;
24
+
22
25
/// List of sources to check, loaded from a .toml file
23
26
#[ derive( Debug , Serialize , Deserialize ) ]
24
27
struct SourceList {
@@ -317,6 +320,9 @@ impl LintcheckConfig {
317
320
let filename: PathBuf = sources_toml_path. file_stem ( ) . unwrap ( ) . into ( ) ;
318
321
let lintcheck_results_path = PathBuf :: from ( format ! ( "lintcheck-logs/{}_logs.txt" , filename. display( ) ) ) ;
319
322
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
320
326
let max_jobs = match clap_config. value_of ( "threads" ) {
321
327
Some ( threads) => {
322
328
let threads: usize = threads
@@ -492,14 +498,12 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> (String, HashMap<&String,
492
498
/// clippy binary, if this is true, we should clean the lintchec shared target directory and recheck
493
499
fn lintcheck_needs_rerun ( toml_path : & PathBuf ) -> bool {
494
500
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
+ } ) ;
503
507
// the oldest modification of either of the binaries
504
508
std:: cmp:: min ( times. next ( ) . unwrap ( ) , times. next ( ) . unwrap ( ) )
505
509
} ;
@@ -539,7 +543,7 @@ pub fn run(clap_config: &ArgMatches) {
539
543
}
540
544
}
541
545
542
- let cargo_clippy_path: PathBuf = PathBuf :: from ( "target/debug/cargo-clippy" )
546
+ let cargo_clippy_path: PathBuf = PathBuf :: from ( CARGO_CLIPPY_PATH )
543
547
. canonicalize ( )
544
548
. expect ( "failed to canonicalize path to clippy binary" ) ;
545
549
@@ -550,7 +554,7 @@ pub fn run(clap_config: &ArgMatches) {
550
554
cargo_clippy_path. display( )
551
555
) ;
552
556
553
- let clippy_ver = std:: process:: Command :: new ( "target/debug/cargo-clippy" )
557
+ let clippy_ver = std:: process:: Command :: new ( CARGO_CLIPPY_PATH )
554
558
. arg ( "--version" )
555
559
. output ( )
556
560
. map ( |o| String :: from_utf8_lossy ( & o. stdout ) . into_owned ( ) )
0 commit comments