diff options
| author | bors <bors@rust-lang.org> | 2023-03-09 17:01:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-09 17:01:20 +0000 |
| commit | a45f71265cc8781c35ca9aa60f6e284d4d121996 (patch) | |
| tree | d2c7b60b818b7547f74eb77fe8a8a3d74c3060f9 | |
| parent | 5f9873497ffb37f9ebdb824b42ce34a8caeec355 (diff) | |
| parent | a701af45cb25cd5a7f45f6b51aa224b7a5d65f3a (diff) | |
| download | rust-a45f71265cc8781c35ca9aa60f6e284d4d121996.tar.gz rust-a45f71265cc8781c35ca9aa60f6e284d4d121996.zip | |
Auto merge of #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
| -rw-r--r-- | lintcheck/src/config.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lintcheck/src/config.rs b/lintcheck/src/config.rs index e1836c19aa2..3f01e9bb0a7 100644 --- a/lintcheck/src/config.rs +++ b/lintcheck/src/config.rs @@ -1,10 +1,16 @@ use clap::Parser; -use std::path::PathBuf; +use std::{num::NonZeroUsize, path::PathBuf}; #[derive(Clone, Debug, Parser)] pub(crate) struct LintcheckConfig { - /// Number of threads to use, 0 automatic choice - #[clap(long = "jobs", short = 'j', value_name = "N", default_value_t = 1)] + /// Number of threads to use (default: all unless --fix or --recursive) + #[clap( + long = "jobs", + short = 'j', + value_name = "N", + default_value_t = 0, + hide_default_value = true + )] pub max_jobs: usize, /// Set the path for a crates.toml where lintcheck should read the sources from #[clap( @@ -51,8 +57,11 @@ impl LintcheckConfig { // look at the --threads arg, if 0 is passed, use the threads count if config.max_jobs == 0 { - // automatic choice - config.max_jobs = std::thread::available_parallelism().map_or(1, |n| n.get()); + config.max_jobs = if config.fix || config.recursive { + 1 + } else { + std::thread::available_parallelism().map_or(1, NonZeroUsize::get) + }; }; for lint_name in &mut config.lint_filter { |
