@@ -229,10 +229,19 @@ impl Crate {
229
229
// "loop" the index within 0..thread_limit
230
230
let target_dir_index = index % thread_limit;
231
231
let perc = ( ( index * 100 ) as f32 / total_crates_to_lint as f32 ) as u8 ;
232
- println ! (
233
- "{}/{} {}% Linting {} {} in target dir {:?}" ,
234
- index, total_crates_to_lint, perc, & self . name, & self . version, target_dir_index
235
- ) ;
232
+
233
+ if thread_limit == 1 {
234
+ println ! (
235
+ "{}/{} {}% Linting {} {}" ,
236
+ index, total_crates_to_lint, perc, & self . name, & self . version
237
+ ) ;
238
+ } else {
239
+ println ! (
240
+ "{}/{} {}% Linting {} {} in target dir {:?}" ,
241
+ index, total_crates_to_lint, perc, & self . name, & self . version, target_dir_index
242
+ ) ;
243
+ }
244
+
236
245
let cargo_clippy_path = std:: fs:: canonicalize ( cargo_clippy_path) . unwrap ( ) ;
237
246
238
247
let shared_target_dir = clippy_project_root ( ) . join ( "target/lintcheck/shared_target_dir" ) ;
@@ -492,8 +501,23 @@ pub fn run(clap_config: &ArgMatches) {
492
501
// This helps when we check many small crates with dep-trees that don't have a lot of branches in
493
502
// order to achive some kind of parallelism
494
503
495
- // Rayon seems to return thread count so half that for core count
496
- let num_cpus: usize = rayon:: current_num_threads ( ) / 2 ;
504
+ // by default, use a single thread
505
+ let num_cpus = match clap_config. value_of ( "threads" ) {
506
+ Some ( threads) => {
507
+ let threads: usize = threads
508
+ . parse ( )
509
+ . expect ( & format ! ( "Failed to parse '{}' to a digit" , threads) ) ;
510
+ if threads == 0 {
511
+ // automatic choice
512
+ // Rayon seems to return thread count so half that for core count
513
+ ( rayon:: current_num_threads ( ) / 2 ) as usize
514
+ } else {
515
+ threads
516
+ }
517
+ } ,
518
+ // no -j passed, use a single thread
519
+ None => 1 ,
520
+ } ;
497
521
498
522
let num_crates = crates. len ( ) ;
499
523
0 commit comments