mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
ci: fix new clippy warnings (#6569)
This commit is contained in:
@@ -40,7 +40,7 @@ fn do_timeout_test(c: &mut Criterion, workers: usize, name: &str) {
|
|||||||
b.iter_custom(|iters| {
|
b.iter_custom(|iters| {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
runtime.block_on(async {
|
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()
|
start.elapsed()
|
||||||
})
|
})
|
||||||
@@ -77,7 +77,7 @@ fn do_sleep_test(c: &mut Criterion, workers: usize, name: &str) {
|
|||||||
b.iter_custom(|iters| {
|
b.iter_custom(|iters| {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
runtime.block_on(async {
|
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()
|
start.elapsed()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ impl Stream for IntervalStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
(std::usize::MAX, None)
|
(usize::MAX, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::codec::decoder::Decoder;
|
|||||||
use crate::codec::encoder::Encoder;
|
use crate::codec::encoder::Encoder;
|
||||||
|
|
||||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
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_SEEK_DELIMITERS: &[u8] = b",;\n\r";
|
||||||
const DEFAULT_SEQUENCE_WRITER: &[u8] = b",";
|
const DEFAULT_SEQUENCE_WRITER: &[u8] = b",";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::codec::decoder::Decoder;
|
|||||||
use crate::codec::encoder::Encoder;
|
use crate::codec::encoder::Encoder;
|
||||||
|
|
||||||
use bytes::{Buf, BufMut, BytesMut};
|
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.
|
/// A simple [`Decoder`] and [`Encoder`] implementation that splits up data into lines.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ pub(crate) use self::stack::Stack;
|
|||||||
|
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::usize;
|
|
||||||
|
|
||||||
/// Timing wheel implementation.
|
/// Timing wheel implementation.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::runtime::{Config, MetricsBatch, WorkerMetrics};
|
use crate::runtime::{Config, MetricsBatch, WorkerMetrics};
|
||||||
|
|
||||||
use std::cmp;
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
/// Per-worker statistics. This is used for both tuning the scheduler and
|
/// 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.
|
// 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;
|
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
|
||||||
// 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.
|
||||||
// global queue always getting checked first.
|
tasks_per_interval.clamp(2, MAX_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL)
|
||||||
2,
|
|
||||||
cmp::min(
|
|
||||||
MAX_TASKS_POLLED_PER_GLOBAL_QUEUE_INTERVAL,
|
|
||||||
tasks_per_interval,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn submit(&mut self, to: &WorkerMetrics) {
|
pub(crate) fn submit(&mut self, to: &WorkerMetrics) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use crate::loom::sync::atomic::AtomicUsize;
|
|||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
|
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
|
||||||
use std::usize;
|
|
||||||
|
|
||||||
pub(super) struct State {
|
pub(super) struct State {
|
||||||
val: AtomicUsize,
|
val: AtomicUsize,
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ impl Semaphore {
|
|||||||
/// implementation used three bits, so we will continue to reserve them to
|
/// 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
|
/// avoid a breaking change if additional flags need to be added in the
|
||||||
/// future.
|
/// future.
|
||||||
pub(crate) const MAX_PERMITS: usize = std::usize::MAX >> 3;
|
pub(crate) const MAX_PERMITS: usize = usize::MAX >> 3;
|
||||||
const CLOSED: usize = 1;
|
const CLOSED: usize = 1;
|
||||||
// The least-significant bit in the number of permits is reserved to use
|
// The least-significant bit in the number of permits is reserved to use
|
||||||
// as a flag indicating that the semaphore has been closed. Consequently
|
// as a flag indicating that the semaphore has been closed. Consequently
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ use std::pin::Pin;
|
|||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
|
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
|
||||||
use std::task::{Context, Poll, Waker};
|
use std::task::{Context, Poll, Waker};
|
||||||
use std::usize;
|
|
||||||
|
|
||||||
/// Sending-half of the [`broadcast`] channel.
|
/// Sending-half of the [`broadcast`] channel.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub(crate) use write_guard::RwLockWriteGuard;
|
|||||||
pub(crate) use write_guard_mapped::RwLockMappedWriteGuard;
|
pub(crate) use write_guard_mapped::RwLockMappedWriteGuard;
|
||||||
|
|
||||||
#[cfg(not(loom))]
|
#[cfg(not(loom))]
|
||||||
const MAX_READS: u32 = std::u32::MAX >> 3;
|
const MAX_READS: u32 = u32::MAX >> 3;
|
||||||
|
|
||||||
#[cfg(loom)]
|
#[cfg(loom)]
|
||||||
const MAX_READS: u32 = 10;
|
const MAX_READS: u32 = 10;
|
||||||
|
|||||||
@@ -286,8 +286,6 @@ fn zero_capacity() {
|
|||||||
#[should_panic]
|
#[should_panic]
|
||||||
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
|
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
|
||||||
fn capacity_too_big() {
|
fn capacity_too_big() {
|
||||||
use std::usize;
|
|
||||||
|
|
||||||
broadcast::channel::<()>(1 + (usize::MAX >> 1));
|
broadcast::channel::<()>(1 + (usize::MAX >> 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user