From 5128601898c788bd1f9cc044eee2859e3b213998 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 28 Jul 2023 20:05:32 +1000 Subject: [PATCH] ci: fix clippy warnings (#5891) Signed-off-by: Jiahao XU --- tokio-stream/src/stream_ext.rs | 6 +++--- tokio-stream/src/stream_ext/take.rs | 6 +++--- tokio-util/src/compat.rs | 4 ++-- tokio/src/io/poll_evented.rs | 2 +- tokio/src/io/util/async_read_ext.rs | 2 +- tokio/src/io/util/async_write_ext.rs | 2 +- tokio/src/net/tcp/socket.rs | 2 +- tokio/src/net/udp.rs | 2 +- tokio/src/net/unix/ucred.rs | 4 ++-- tokio/src/runtime/task/harness.rs | 2 +- tokio/src/runtime/task/list.rs | 2 +- tokio/src/runtime/task/waker.rs | 4 +--- 12 files changed, 18 insertions(+), 20 deletions(-) diff --git a/tokio-stream/src/stream_ext.rs b/tokio-stream/src/stream_ext.rs index a4ab8a036..8b457b87b 100644 --- a/tokio-stream/src/stream_ext.rs +++ b/tokio-stream/src/stream_ext.rs @@ -994,7 +994,7 @@ pub trait StreamExt: Stream { /// assert!(timeout_stream.try_next().await.is_ok(), "expected no more timeouts"); /// # } /// ``` - #[cfg(all(feature = "time"))] + #[cfg(feature = "time")] #[cfg_attr(docsrs, doc(cfg(feature = "time")))] fn timeout(self, duration: Duration) -> Timeout where @@ -1083,7 +1083,7 @@ pub trait StreamExt: Stream { /// assert!(timeout_stream.try_next().await.is_ok(), "expected non-timeout"); /// # } /// ``` - #[cfg(all(feature = "time"))] + #[cfg(feature = "time")] #[cfg_attr(docsrs, doc(cfg(feature = "time")))] fn timeout_repeating(self, interval: Interval) -> TimeoutRepeating where @@ -1113,7 +1113,7 @@ pub trait StreamExt: Stream { /// } /// # } /// ``` - #[cfg(all(feature = "time"))] + #[cfg(feature = "time")] #[cfg_attr(docsrs, doc(cfg(feature = "time")))] fn throttle(self, duration: Duration) -> Throttle where diff --git a/tokio-stream/src/stream_ext/take.rs b/tokio-stream/src/stream_ext/take.rs index c75648f60..07b5c3d57 100644 --- a/tokio-stream/src/stream_ext/take.rs +++ b/tokio-stream/src/stream_ext/take.rs @@ -64,11 +64,11 @@ where let (lower, upper) = self.stream.size_hint(); - let lower = cmp::min(lower, self.remaining as usize); + let lower = cmp::min(lower, self.remaining); let upper = match upper { - Some(x) if x < self.remaining as usize => Some(x), - _ => Some(self.remaining as usize), + Some(x) if x < self.remaining => Some(x), + _ => Some(self.remaining), }; (lower, upper) diff --git a/tokio-util/src/compat.rs b/tokio-util/src/compat.rs index 6e19b2bd2..423bd956d 100644 --- a/tokio-util/src/compat.rs +++ b/tokio-util/src/compat.rs @@ -234,7 +234,7 @@ impl futures_io::AsyncSeek for Compat { } let res = ready!(self.as_mut().project().inner.poll_complete(cx)); *self.as_mut().project().seek_pos = None; - Poll::Ready(res.map(|p| p as u64)) + Poll::Ready(res) } } @@ -257,7 +257,7 @@ impl tokio::io::AsyncSeek for Compat { }; let res = ready!(self.as_mut().project().inner.poll_seek(cx, pos)); *self.as_mut().project().seek_pos = None; - Poll::Ready(res.map(|p| p as u64)) + Poll::Ready(res) } } diff --git a/tokio/src/io/poll_evented.rs b/tokio/src/io/poll_evented.rs index f5e8cffb8..cb5bffd54 100644 --- a/tokio/src/io/poll_evented.rs +++ b/tokio/src/io/poll_evented.rs @@ -124,7 +124,7 @@ impl PollEvented { } /// Returns a reference to the registration. - #[cfg(any(feature = "net"))] + #[cfg(feature = "net")] pub(crate) fn registration(&self) -> &Registration { &self.registration } diff --git a/tokio/src/io/util/async_read_ext.rs b/tokio/src/io/util/async_read_ext.rs index 3201f1dd0..179e4834d 100644 --- a/tokio/src/io/util/async_read_ext.rs +++ b/tokio/src/io/util/async_read_ext.rs @@ -27,7 +27,7 @@ cfg_io_util! { ) => { $( $(#[$outer])* - fn $name<'a>(&'a mut self) -> $($fut)*<&'a mut Self> where Self: Unpin { + fn $name(&mut self) -> $($fut)*<&mut Self> where Self: Unpin { $($fut)*::new(self) } )* diff --git a/tokio/src/io/util/async_write_ext.rs b/tokio/src/io/util/async_write_ext.rs index dfdde82f3..a9812d57e 100644 --- a/tokio/src/io/util/async_write_ext.rs +++ b/tokio/src/io/util/async_write_ext.rs @@ -30,7 +30,7 @@ cfg_io_util! { ) => { $( $(#[$outer])* - fn $name<'a>(&'a mut self, n: $ty) -> $($fut)*<&'a mut Self> where Self: Unpin { + fn $name(&mut self, n: $ty) -> $($fut)*<&mut Self> where Self: Unpin { $($fut)*::new(self, n) } )* diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 5c7030d82..313ace2f3 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -523,7 +523,7 @@ impl TcpSocket { /// works for some socket types, particularly `AF_INET` sockets. /// /// If `interface` is `None` or an empty string it removes the binding. - #[cfg(all(any(target_os = "android", target_os = "fuchsia", target_os = "linux")))] + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg_attr( docsrs, doc(cfg(all(any(target_os = "android", target_os = "fuchsia", target_os = "linux")))) diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index cd3d6a85d..f1caa2a5c 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1921,7 +1921,7 @@ impl UdpSocket { /// works for some socket types, particularly `AF_INET` sockets. /// /// If `interface` is `None` or an empty string it removes the binding. - #[cfg(all(any(target_os = "android", target_os = "fuchsia", target_os = "linux")))] + #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[cfg_attr( docsrs, doc(cfg(all(any(target_os = "android", target_os = "fuchsia", target_os = "linux")))) diff --git a/tokio/src/net/unix/ucred.rs b/tokio/src/net/unix/ucred.rs index 556c8fecb..43f008b21 100644 --- a/tokio/src/net/unix/ucred.rs +++ b/tokio/src/net/unix/ucred.rs @@ -39,7 +39,7 @@ impl UCred { ))] pub(crate) use self::impl_linux::get_peer_cred; -#[cfg(any(target_os = "netbsd"))] +#[cfg(target_os = "netbsd")] pub(crate) use self::impl_netbsd::get_peer_cred; #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] @@ -114,7 +114,7 @@ pub(crate) mod impl_linux { } } -#[cfg(any(target_os = "netbsd"))] +#[cfg(target_os = "netbsd")] pub(crate) mod impl_netbsd { use crate::net::unix::{self, UnixStream}; diff --git a/tokio/src/runtime/task/harness.rs b/tokio/src/runtime/task/harness.rs index 13c46bbf7..8bfd57e6f 100644 --- a/tokio/src/runtime/task/harness.rs +++ b/tokio/src/runtime/task/harness.rs @@ -203,7 +203,7 @@ where } } let header_ptr = self.header_ptr(); - let waker_ref = waker_ref::(&header_ptr); + let waker_ref = waker_ref::(&header_ptr); let cx = Context::from_waker(&waker_ref); let res = poll_future(self.core(), cx); diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index 3d2f57404..3a1fcce2e 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -303,7 +303,7 @@ impl LocalOwnedTasks { } } -#[cfg(all(test))] +#[cfg(test)] mod tests { use super::*; diff --git a/tokio/src/runtime/task/waker.rs b/tokio/src/runtime/task/waker.rs index b5f5ace9e..2a1568fe8 100644 --- a/tokio/src/runtime/task/waker.rs +++ b/tokio/src/runtime/task/waker.rs @@ -1,4 +1,3 @@ -use crate::future::Future; use crate::runtime::task::{Header, RawTask, Schedule}; use std::marker::PhantomData; @@ -14,9 +13,8 @@ pub(super) struct WakerRef<'a, S: 'static> { /// Returns a `WakerRef` which avoids having to preemptively increase the /// refcount if there is no need to do so. -pub(super) fn waker_ref(header: &NonNull
) -> WakerRef<'_, S> +pub(super) fn waker_ref(header: &NonNull
) -> WakerRef<'_, S> where - T: Future, S: Schedule, { // `Waker::will_wake` uses the VTABLE pointer as part of the check. This