Enforce NonZeroUsize on thread count

This allows avoiding some if != 0 checks when allocating worker-local
datasets.
This commit is contained in:
Mark Rousskov 2023-11-23 20:10:44 -05:00
parent a4a5c976fe
commit ee9223ff97
2 changed files with 8 additions and 5 deletions

View file

@ -107,7 +107,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
use rustc_query_impl::QueryCtxt;
use rustc_query_system::query::{deadlock, QueryContext};
let registry = sync::Registry::new(threads);
let registry = sync::Registry::new(std::num::NonZeroUsize::new(threads).unwrap());
if !sync::is_dyn_thread_safe() {
return run_in_thread_with_globals(edition, || {