From b2f739340c4b04388d1492ec498236738e7c0e4e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 2 May 2024 13:51:04 -0700 Subject: [PATCH] Fix `clippy::legacy_numeric_constants` --- rayon-core/src/latch.rs | 1 - rayon-core/src/registry.rs | 6 +----- rayon-core/src/sleep/counters.rs | 2 +- rayon-core/src/sleep/mod.rs | 1 - rayon-demo/src/tsp/solver.rs | 1 - rayon-demo/src/tsp/weight.rs | 1 - src/iter/blocks.rs | 2 +- src/iter/enumerate.rs | 1 - src/iter/find_first_last/mod.rs | 4 ++-- src/iter/plumbing/mod.rs | 2 -- src/iter/repeat.rs | 1 - src/iter/step_by.rs | 1 - src/slice/mod.rs | 6 +++--- 13 files changed, 8 insertions(+), 21 deletions(-) diff --git a/rayon-core/src/latch.rs b/rayon-core/src/latch.rs index 6c2e4fe97..9410ab8e0 100644 --- a/rayon-core/src/latch.rs +++ b/rayon-core/src/latch.rs @@ -2,7 +2,6 @@ use std::marker::PhantomData; use std::ops::Deref; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; -use std::usize; use crate::registry::{Registry, WorkerThread}; use crate::sync::{Condvar, Mutex}; diff --git a/rayon-core/src/registry.rs b/rayon-core/src/registry.rs index 46cd22b31..d30f815bd 100644 --- a/rayon-core/src/registry.rs +++ b/rayon-core/src/registry.rs @@ -18,7 +18,6 @@ use std::ptr; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Once}; use std::thread; -use std::usize; /// Thread builder used for customization via /// [`ThreadPoolBuilder::spawn_handler`](struct.ThreadPoolBuilder.html#method.spawn_handler). @@ -576,10 +575,7 @@ impl Registry { pub(super) fn increment_terminate_count(&self) { let previous = self.terminate_count.fetch_add(1, Ordering::AcqRel); debug_assert!(previous != 0, "registry ref count incremented from zero"); - assert!( - previous != std::usize::MAX, - "overflow in registry ref count" - ); + assert!(previous != usize::MAX, "overflow in registry ref count"); } /// Signals that the thread-pool which owns this registry has been diff --git a/rayon-core/src/sleep/counters.rs b/rayon-core/src/sleep/counters.rs index 96db5dca2..05941becd 100644 --- a/rayon-core/src/sleep/counters.rs +++ b/rayon-core/src/sleep/counters.rs @@ -27,7 +27,7 @@ pub(super) struct Counters { pub(super) struct JobsEventCounter(usize); impl JobsEventCounter { - pub(super) const DUMMY: JobsEventCounter = JobsEventCounter(std::usize::MAX); + pub(super) const DUMMY: JobsEventCounter = JobsEventCounter(usize::MAX); #[inline] pub(super) fn as_usize(self) -> usize { diff --git a/rayon-core/src/sleep/mod.rs b/rayon-core/src/sleep/mod.rs index acef9bf64..9b02b39b5 100644 --- a/rayon-core/src/sleep/mod.rs +++ b/rayon-core/src/sleep/mod.rs @@ -6,7 +6,6 @@ use crate::sync::{Condvar, Mutex}; use crossbeam_utils::CachePadded; use std::sync::atomic::Ordering; use std::thread; -use std::usize; mod counters; pub(crate) use self::counters::THREADS_MAX; diff --git a/rayon-demo/src/tsp/solver.rs b/rayon-demo/src/tsp/solver.rs index f41c347ec..c29f299b7 100644 --- a/rayon-demo/src/tsp/solver.rs +++ b/rayon-demo/src/tsp/solver.rs @@ -1,7 +1,6 @@ use std::collections::BinaryHeap; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; -use std::usize; use super::graph::{Graph, Node}; use super::step; diff --git a/rayon-demo/src/tsp/weight.rs b/rayon-demo/src/tsp/weight.rs index 38dafe419..f7d3fc0fc 100644 --- a/rayon-demo/src/tsp/weight.rs +++ b/rayon-demo/src/tsp/weight.rs @@ -1,5 +1,4 @@ use std::ops::{Add, AddAssign, Sub, SubAssign}; -use std::usize; #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Weight { diff --git a/src/iter/blocks.rs b/src/iter/blocks.rs index 0d4e06c15..1691e8b15 100644 --- a/src/iter/blocks.rs +++ b/src/iter/blocks.rs @@ -27,7 +27,7 @@ where // now we loop on each block size while remaining_len > 0 && !consumer.full() { // we compute the next block's size - let size = self.sizes.next().unwrap_or(std::usize::MAX); + let size = self.sizes.next().unwrap_or(usize::MAX); let capped_size = remaining_len.min(size); remaining_len -= capped_size; diff --git a/src/iter/enumerate.rs b/src/iter/enumerate.rs index 980ee7cc7..9d58b6ca0 100644 --- a/src/iter/enumerate.rs +++ b/src/iter/enumerate.rs @@ -2,7 +2,6 @@ use super::plumbing::*; use super::*; use std::iter; use std::ops::Range; -use std::usize; /// `Enumerate` is an iterator that returns the current count along with the element. /// This struct is created by the [`enumerate()`] method on [`IndexedParallelIterator`] diff --git a/src/iter/find_first_last/mod.rs b/src/iter/find_first_last/mod.rs index a241373f9..4b9bf44b7 100644 --- a/src/iter/find_first_last/mod.rs +++ b/src/iter/find_first_last/mod.rs @@ -43,7 +43,7 @@ where I: ParallelIterator, P: Fn(&I::Item) -> bool + Sync, { - let best_found = AtomicUsize::new(usize::max_value()); + let best_found = AtomicUsize::new(usize::MAX); let consumer = FindConsumer::new(&find_op, MatchPosition::Leftmost, &best_found); pi.drive_unindexed(consumer) } @@ -71,7 +71,7 @@ impl<'p, P> FindConsumer<'p, P> { FindConsumer { find_op, lower_bound: Cell::new(0), - upper_bound: usize::max_value(), + upper_bound: usize::MAX, match_position, best_found, } diff --git a/src/iter/plumbing/mod.rs b/src/iter/plumbing/mod.rs index 9d08daacc..da6223285 100644 --- a/src/iter/plumbing/mod.rs +++ b/src/iter/plumbing/mod.rs @@ -8,8 +8,6 @@ use crate::join_context; use super::IndexedParallelIterator; -use std::usize; - /// The `ProducerCallback` trait is a kind of generic closure, /// [analogous to `FnOnce`][FnOnce]. See [the corresponding section in /// the plumbing README][r] for more details. diff --git a/src/iter/repeat.rs b/src/iter/repeat.rs index f84a6fe77..f8843edc8 100644 --- a/src/iter/repeat.rs +++ b/src/iter/repeat.rs @@ -1,7 +1,6 @@ use super::plumbing::*; use super::*; use std::iter; -use std::usize; /// Iterator adaptor for [the `repeat()` function](fn.repeat.html). #[derive(Debug, Clone)] diff --git a/src/iter/step_by.rs b/src/iter/step_by.rs index daf2806a6..4074d6880 100644 --- a/src/iter/step_by.rs +++ b/src/iter/step_by.rs @@ -2,7 +2,6 @@ use super::plumbing::*; use super::*; use crate::math::div_round_up; use std::iter; -use std::usize; /// `StepBy` is an iterator that skips `n` elements between each yield, where `n` is the given step. /// This struct is created by the [`step_by()`] method on [`IndexedParallelIterator`] diff --git a/src/slice/mod.rs b/src/slice/mod.rs index b1555a78d..25e911663 100644 --- a/src/slice/mod.rs +++ b/src/slice/mod.rs @@ -572,13 +572,13 @@ pub trait ParallelSliceMut { let sz_u32 = mem::size_of::<(K, u32)>(); let sz_usize = mem::size_of::<(K, usize)>(); - if sz_u8 < sz_u16 && len <= (std::u8::MAX as usize) { + if sz_u8 < sz_u16 && len <= (u8::MAX as usize) { return sort_by_key!(u8); } - if sz_u16 < sz_u32 && len <= (std::u16::MAX as usize) { + if sz_u16 < sz_u32 && len <= (u16::MAX as usize) { return sort_by_key!(u16); } - if sz_u32 < sz_usize && len <= (std::u32::MAX as usize) { + if sz_u32 < sz_usize && len <= (u32::MAX as usize) { return sort_by_key!(u32); } sort_by_key!(usize)