diff --git a/benches/time_timeout.rs b/benches/time_timeout.rs index c96147756..9dedee9dd 100644 --- a/benches/time_timeout.rs +++ b/benches/time_timeout.rs @@ -40,7 +40,7 @@ fn do_timeout_test(c: &mut Criterion, workers: usize, name: &str) { b.iter_custom(|iters| { let start = Instant::now(); runtime.block_on(async { - black_box(spawn_timeout_job(iters as usize, workers).await); + black_box(spawn_timeout_job(iters as usize, workers)).await; }); start.elapsed() }) @@ -77,7 +77,7 @@ fn do_sleep_test(c: &mut Criterion, workers: usize, name: &str) { b.iter_custom(|iters| { let start = Instant::now(); runtime.block_on(async { - black_box(spawn_sleep_job(iters as usize, workers).await); + black_box(spawn_sleep_job(iters as usize, workers)).await; }); start.elapsed() }) diff --git a/tokio-stream/src/wrappers/interval.rs b/tokio-stream/src/wrappers/interval.rs index 2bf0194bd..c7a0b1f1e 100644 --- a/tokio-stream/src/wrappers/interval.rs +++ b/tokio-stream/src/wrappers/interval.rs @@ -33,7 +33,7 @@ impl Stream for IntervalStream { } fn size_hint(&self) -> (usize, Option) { - (std::usize::MAX, None) + (usize::MAX, None) } } diff --git a/tokio-util/src/codec/any_delimiter_codec.rs b/tokio-util/src/codec/any_delimiter_codec.rs index 3dbfd456b..fc5e57582 100644 --- a/tokio-util/src/codec/any_delimiter_codec.rs +++ b/tokio-util/src/codec/any_delimiter_codec.rs @@ -2,7 +2,7 @@ use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use bytes::{Buf, BufMut, Bytes, BytesMut}; -use std::{cmp, fmt, io, str, usize}; +use std::{cmp, fmt, io, str}; const DEFAULT_SEEK_DELIMITERS: &[u8] = b",;\n\r"; const DEFAULT_SEQUENCE_WRITER: &[u8] = b","; diff --git a/tokio-util/src/codec/lines_codec.rs b/tokio-util/src/codec/lines_codec.rs index 5a6035d13..0da19238b 100644 --- a/tokio-util/src/codec/lines_codec.rs +++ b/tokio-util/src/codec/lines_codec.rs @@ -2,7 +2,7 @@ use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use bytes::{Buf, BufMut, BytesMut}; -use std::{cmp, fmt, io, str, usize}; +use std::{cmp, fmt, io, str}; /// A simple [`Decoder`] and [`Encoder`] implementation that splits up data into lines. /// diff --git a/tokio-util/src/time/wheel/mod.rs b/tokio-util/src/time/wheel/mod.rs index 10a9900a6..d81611c92 100644 --- a/tokio-util/src/time/wheel/mod.rs +++ b/tokio-util/src/time/wheel/mod.rs @@ -7,7 +7,6 @@ pub(crate) use self::stack::Stack; use std::borrow::Borrow; use std::fmt::Debug; -use std::usize; /// Timing wheel implementation. /// diff --git a/tokio/src/runtime/scheduler/multi_thread/stats.rs b/tokio/src/runtime/scheduler/multi_thread/stats.rs index 03cfc7900..9d495706e 100644 --- a/tokio/src/runtime/scheduler/multi_thread/stats.rs +++ b/tokio/src/runtime/scheduler/multi_thread/stats.rs @@ -1,6 +1,5 @@ use crate::runtime::{Config, MetricsBatch, WorkerMetrics}; -use std::cmp; use std::time::{Duration, Instant}; /// Per-worker statistics. This is used for both tuning the scheduler and @@ -62,15 +61,9 @@ impl Stats { // As of Rust 1.45, casts from f64 -> u32 are saturating, which is fine here. let tasks_per_interval = (TARGET_GLOBAL_QUEUE_INTERVAL / self.task_poll_time_ewma) as u32; - cmp::max( - // If we are using self-tuning, we don't want to return less than 2 as that would result in the - // global queue always getting checked first. - 2, - cmp::min( - MAX_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL, - tasks_per_interval, - ), - ) + // If we are using self-tuning, we don't want to return less than 2 as that would result in the + // global queue always getting checked first. + tasks_per_interval.clamp(2, MAX_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL) } pub(crate) fn submit(&mut self, to: &WorkerMetrics) { diff --git a/tokio/src/runtime/task/state.rs b/tokio/src/runtime/task/state.rs index 42b239e05..0fc7bb032 100644 --- a/tokio/src/runtime/task/state.rs +++ b/tokio/src/runtime/task/state.rs @@ -2,7 +2,6 @@ use crate::loom::sync::atomic::AtomicUsize; use std::fmt; use std::sync::atomic::Ordering::{AcqRel, Acquire, Release}; -use std::usize; pub(super) struct State { val: AtomicUsize, diff --git a/tokio/src/sync/batch_semaphore.rs b/tokio/src/sync/batch_semaphore.rs index def5cbc9f..a241f7922 100644 --- a/tokio/src/sync/batch_semaphore.rs +++ b/tokio/src/sync/batch_semaphore.rs @@ -127,7 +127,7 @@ impl Semaphore { /// implementation used three bits, so we will continue to reserve them to /// avoid a breaking change if additional flags need to be added in the /// future. - pub(crate) const MAX_PERMITS: usize = std::usize::MAX >> 3; + pub(crate) const MAX_PERMITS: usize = usize::MAX >> 3; const CLOSED: usize = 1; // The least-significant bit in the number of permits is reserved to use // as a flag indicating that the semaphore has been closed. Consequently diff --git a/tokio/src/sync/broadcast.rs b/tokio/src/sync/broadcast.rs index 326b81b4d..ba0a44fb8 100644 --- a/tokio/src/sync/broadcast.rs +++ b/tokio/src/sync/broadcast.rs @@ -129,7 +129,6 @@ use std::pin::Pin; use std::ptr::NonNull; use std::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst}; use std::task::{Context, Poll, Waker}; -use std::usize; /// Sending-half of the [`broadcast`] channel. /// diff --git a/tokio/src/sync/rwlock.rs b/tokio/src/sync/rwlock.rs index 37cf73c59..14983d5cb 100644 --- a/tokio/src/sync/rwlock.rs +++ b/tokio/src/sync/rwlock.rs @@ -21,7 +21,7 @@ pub(crate) use write_guard::RwLockWriteGuard; pub(crate) use write_guard_mapped::RwLockMappedWriteGuard; #[cfg(not(loom))] -const MAX_READS: u32 = std::u32::MAX >> 3; +const MAX_READS: u32 = u32::MAX >> 3; #[cfg(loom)] const MAX_READS: u32 = 10; diff --git a/tokio/tests/sync_broadcast.rs b/tokio/tests/sync_broadcast.rs index 17fe44f3e..2638c1f33 100644 --- a/tokio/tests/sync_broadcast.rs +++ b/tokio/tests/sync_broadcast.rs @@ -286,8 +286,6 @@ fn zero_capacity() { #[should_panic] #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding fn capacity_too_big() { - use std::usize; - broadcast::channel::<()>(1 + (usize::MAX >> 1)); }