Skip to content

Commit

Permalink
ci: fix clippy warnings (#5891)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Jul 28, 2023
1 parent c445e46 commit 5128601
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions tokio-stream/src/stream_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>
where
Expand Down Expand Up @@ -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<Self>
where
Expand Down Expand Up @@ -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<Self>
where
Expand Down
6 changes: 3 additions & 3 deletions tokio-stream/src/stream_ext/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tokio-util/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl<T: tokio::io::AsyncSeek> futures_io::AsyncSeek for Compat<T> {
}
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)
}
}

Expand All @@ -257,7 +257,7 @@ impl<T: futures_io::AsyncSeek> tokio::io::AsyncSeek for Compat<T> {
};
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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/poll_evented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<E: Source> PollEvented<E> {
}

/// Returns a reference to the registration.
#[cfg(any(feature = "net"))]
#[cfg(feature = "net")]
pub(crate) fn registration(&self) -> &Registration {
&self.registration
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/util/async_read_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)*
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/util/async_write_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)*
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/tcp/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/net/unix/ucred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/task/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ where
}
}
let header_ptr = self.header_ptr();
let waker_ref = waker_ref::<T, S>(&header_ptr);
let waker_ref = waker_ref::<S>(&header_ptr);
let cx = Context::from_waker(&waker_ref);
let res = poll_future(self.core(), cx);

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/task/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<S: 'static> LocalOwnedTasks<S> {
}
}

#[cfg(all(test))]
#[cfg(test)]
mod tests {
use super::*;

Expand Down
4 changes: 1 addition & 3 deletions tokio/src/runtime/task/waker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::future::Future;
use crate::runtime::task::{Header, RawTask, Schedule};

use std::marker::PhantomData;
Expand All @@ -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<T, S>(header: &NonNull<Header>) -> WakerRef<'_, S>
pub(super) fn waker_ref<S>(header: &NonNull<Header>) -> WakerRef<'_, S>
where
T: Future,
S: Schedule,
{
// `Waker::will_wake` uses the VTABLE pointer as part of the check. This
Expand Down

0 comments on commit 5128601

Please sign in to comment.