Skip to content

Commit a45f712

Browse files
committed
Auto merge of rust-lang#10458 - samueltardieu:multithreading-lintcheck, r=llogiq
lintcheck: use multithreading unless --fix or --recursive is used Use multithreading unless there is a reason not to. changelog: none
2 parents 5f98734 + a701af4 commit a45f712

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lintcheck/src/config.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
use clap::Parser;
2-
use std::path::PathBuf;
2+
use std::{num::NonZeroUsize, path::PathBuf};
33

44
#[derive(Clone, Debug, Parser)]
55
pub(crate) struct LintcheckConfig {
6-
/// Number of threads to use, 0 automatic choice
7-
#[clap(long = "jobs", short = 'j', value_name = "N", default_value_t = 1)]
6+
/// Number of threads to use (default: all unless --fix or --recursive)
7+
#[clap(
8+
long = "jobs",
9+
short = 'j',
10+
value_name = "N",
11+
default_value_t = 0,
12+
hide_default_value = true
13+
)]
814
pub max_jobs: usize,
915
/// Set the path for a crates.toml where lintcheck should read the sources from
1016
#[clap(
@@ -51,8 +57,11 @@ impl LintcheckConfig {
5157

5258
// look at the --threads arg, if 0 is passed, use the threads count
5359
if config.max_jobs == 0 {
54-
// automatic choice
55-
config.max_jobs = std::thread::available_parallelism().map_or(1, |n| n.get());
60+
config.max_jobs = if config.fix || config.recursive {
61+
1
62+
} else {
63+
std::thread::available_parallelism().map_or(1, NonZeroUsize::get)
64+
};
5665
};
5766

5867
for lint_name in &mut config.lint_filter {

0 commit comments

Comments
 (0)