mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
fix clippy (#1737)
This commit is contained in:
+1
-1
@@ -12,5 +12,5 @@ jobs:
|
|||||||
cargo clippy --version
|
cargo clippy --version
|
||||||
displayName: Install clippy
|
displayName: Install clippy
|
||||||
- script: |
|
- script: |
|
||||||
cargo clippy --all --all-features -- -A clippy::mutex-atomic
|
cargo clippy --all --all-features -- -A clippy::mutex-atomic -A clippy::needless-doctest-main
|
||||||
displayName: cargo clippy --all
|
displayName: cargo clippy --all
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ pub trait AsyncRead {
|
|||||||
///
|
///
|
||||||
/// This function is called from [`poll_read_buf`].
|
/// This function is called from [`poll_read_buf`].
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// Implementations that return `false` must never read from data slices
|
||||||
|
/// that they did not write to.
|
||||||
|
///
|
||||||
/// [`io::Read`]: std::io::Read
|
/// [`io::Read`]: std::io::Read
|
||||||
/// [`poll_read_buf`]: #method.poll_read_buf
|
/// [`poll_read_buf`]: #method.poll_read_buf
|
||||||
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
|
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ impl Command {
|
|||||||
/// will be called and the spawn operation will immediately return with a
|
/// will be called and the spawn operation will immediately return with a
|
||||||
/// failure.
|
/// failure.
|
||||||
///
|
///
|
||||||
/// # Notes and Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// This closure will be run in the context of the child process after a
|
/// This closure will be run in the context of the child process after a
|
||||||
/// `fork`. This primarily means that any modifications made to memory on
|
/// `fork`. This primarily means that any modifications made to memory on
|
||||||
|
|||||||
@@ -337,6 +337,8 @@ impl fmt::Debug for Scheduler {
|
|||||||
|
|
||||||
unsafe fn sched_clone_waker(ptr: *const ()) -> RawWaker {
|
unsafe fn sched_clone_waker(ptr: *const ()) -> RawWaker {
|
||||||
let s1 = ManuallyDrop::new(Arc::from_raw(ptr as *const Scheduler));
|
let s1 = ManuallyDrop::new(Arc::from_raw(ptr as *const Scheduler));
|
||||||
|
|
||||||
|
#[allow(clippy::redundant_clone)]
|
||||||
let s2 = s1.clone();
|
let s2 = s1.clone();
|
||||||
|
|
||||||
RawWaker::new(
|
RawWaker::new(
|
||||||
|
|||||||
@@ -358,8 +358,6 @@ where
|
|||||||
park: &mut impl Park<Unpark = P>,
|
park: &mut impl Park<Unpark = P>,
|
||||||
gone: &Cell<bool>,
|
gone: &Cell<bool>,
|
||||||
) -> Result<bool, WorkerGone> {
|
) -> Result<bool, WorkerGone> {
|
||||||
debug_assert!(self.is_running());
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let tick = self.tick_fetch_inc();
|
let tick = self.tick_fetch_inc();
|
||||||
|
|
||||||
@@ -412,8 +410,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn search_for_work(&mut self, gone: &Cell<bool>) -> Result<bool, WorkerGone> {
|
fn search_for_work(&mut self, gone: &Cell<bool>) -> Result<bool, WorkerGone> {
|
||||||
debug_assert!(self.is_searching());
|
|
||||||
|
|
||||||
if let Some(task) = self.steal_work() {
|
if let Some(task) = self.steal_work() {
|
||||||
self.run_task(task, gone)?;
|
self.run_task(task, gone)?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
@@ -435,8 +431,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn transition_from_searching(&mut self) {
|
fn transition_from_searching(&mut self) {
|
||||||
debug_assert!(self.is_searching());
|
|
||||||
|
|
||||||
self.owned().is_searching.set(false);
|
self.owned().is_searching.set(false);
|
||||||
|
|
||||||
if self.set().idle().transition_worker_from_searching() {
|
if self.set().idle().transition_worker_from_searching() {
|
||||||
|
|||||||
@@ -298,7 +298,6 @@ impl<T: Clone> Receiver<T> {
|
|||||||
impl<T: Clone> futures_core::Stream for Receiver<T> {
|
impl<T: Clone> futures_core::Stream for Receiver<T> {
|
||||||
type Item = T;
|
type Item = T;
|
||||||
|
|
||||||
#[allow(clippy::map_clone)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3274
|
|
||||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<T>> {
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<T>> {
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
@@ -306,7 +305,7 @@ impl<T: Clone> futures_core::Stream for Receiver<T> {
|
|||||||
pin_mut!(fut);
|
pin_mut!(fut);
|
||||||
|
|
||||||
let item = ready!(fut.poll(cx));
|
let item = ready!(fut.poll(cx));
|
||||||
Ready(item.map(|v_ref| v_ref.clone()))
|
Ready(item.map(|v_ref| v_ref))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,19 +173,7 @@ where
|
|||||||
if let Some(expiration) = self.levels[level].next_expiration(self.elapsed) {
|
if let Some(expiration) = self.levels[level].next_expiration(self.elapsed) {
|
||||||
// There cannot be any expirations at a higher level that happen
|
// There cannot be any expirations at a higher level that happen
|
||||||
// before this one.
|
// before this one.
|
||||||
debug_assert!({
|
debug_assert!(self.no_expirations_before(level + 1, expiration.deadline));
|
||||||
let mut res = true;
|
|
||||||
|
|
||||||
for l2 in (level + 1)..NUM_LEVELS {
|
|
||||||
if let Some(e2) = self.levels[l2].next_expiration(self.elapsed) {
|
|
||||||
if e2.deadline < expiration.deadline {
|
|
||||||
res = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res
|
|
||||||
});
|
|
||||||
|
|
||||||
return Some(expiration);
|
return Some(expiration);
|
||||||
}
|
}
|
||||||
@@ -194,6 +182,21 @@ where
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Used for debug assertions
|
||||||
|
fn no_expirations_before(&self, start_level: usize, before: u64) -> bool {
|
||||||
|
let mut res = true;
|
||||||
|
|
||||||
|
for l2 in start_level..NUM_LEVELS {
|
||||||
|
if let Some(e2) = self.levels[l2].next_expiration(self.elapsed) {
|
||||||
|
if e2.deadline < before {
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn poll_expiration(
|
pub(crate) fn poll_expiration(
|
||||||
&mut self,
|
&mut self,
|
||||||
expiration: &Expiration,
|
expiration: &Expiration,
|
||||||
|
|||||||
Reference in New Issue
Block a user