Skip to content

Commit 7a15061

Browse files
committed
tests: use std::thread::available_parallelism() instead of num_cpus to get thread count
removes the dependency added in rust-lang/rust-clippy#8451
1 parent 28b1fe5 commit 7a15061

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ futures = "0.3"
5151
parking_lot = "0.11.2"
5252
tokio = { version = "1", features = ["io-util"] }
5353
rustc-semver = "1.1"
54-
num_cpus = "1.13"
5554

5655
[build-dependencies]
5756
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }

tests/compile-test.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ fn run_ui() {
168168
let _threads = VarGuard::set(
169169
"RUST_TEST_THREADS",
170170
// if RUST_TEST_THREADS is set, adhere to it, otherwise override it
171-
env::var("RUST_TEST_THREADS").unwrap_or_else(|_| num_cpus::get().to_string()),
171+
env::var("RUST_TEST_THREADS").unwrap_or_else(|_| {
172+
std::thread::available_parallelism()
173+
.map_or(1, std::num::NonZeroUsize::get)
174+
.to_string()
175+
}),
172176
);
173177
compiletest::run_tests(&config);
174178
}

0 commit comments

Comments
 (0)