Skip to content

Commit

Permalink
Merge pull request #1162 from cuviper/legacy_numeric_constants
Browse files Browse the repository at this point in the history
Fix `clippy::legacy_numeric_constants`
  • Loading branch information
cuviper authored May 2, 2024
2 parents 0e8d45d + b2f7393 commit 3e3962c
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 21 deletions.
1 change: 0 additions & 1 deletion rayon-core/src/latch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 1 addition & 5 deletions rayon-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/sleep/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion rayon-core/src/sleep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion rayon-demo/src/tsp/solver.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion rayon-demo/src/tsp/weight.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/iter/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/iter/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`]
Expand Down
4 changes: 2 additions & 2 deletions src/iter/find_first_last/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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,
}
Expand Down
2 changes: 0 additions & 2 deletions src/iter/plumbing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/iter/repeat.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
1 change: 0 additions & 1 deletion src/iter/step_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`]
Expand Down
6 changes: 3 additions & 3 deletions src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,13 @@ pub trait ParallelSliceMut<T: Send> {
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)
Expand Down

0 comments on commit 3e3962c

Please sign in to comment.