chore: fix clippy warnings (#6466)

This commit is contained in:
Rafael Bachmann
2024-04-08 20:44:18 +09:00
committed by GitHub
parent b6d74ac4eb
commit be9328da75
15 changed files with 29 additions and 12 deletions
+2 -2
View File
@@ -259,11 +259,11 @@ mod date {
unix_date: u64, unix_date: u64,
} }
thread_local!(static LAST: RefCell<LastRenderedNow> = RefCell::new(LastRenderedNow { thread_local!(static LAST: RefCell<LastRenderedNow> = const { RefCell::new(LastRenderedNow {
bytes: [0; 128], bytes: [0; 128],
amt: 0, amt: 0,
unix_date: 0, unix_date: 0,
})); }) });
impl fmt::Display for Now { impl fmt::Display for Now {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+4 -4
View File
@@ -467,10 +467,10 @@ impl<K, V> StreamMap<K, V> {
/// assert!(map.remove(&1).is_some()); /// assert!(map.remove(&1).is_some());
/// assert!(map.remove(&1).is_none()); /// assert!(map.remove(&1).is_none());
/// ``` /// ```
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V> pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
where where
K: Borrow<Q>, K: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq + ?Sized,
{ {
for i in 0..self.entries.len() { for i in 0..self.entries.len() {
if self.entries[i].0.borrow() == k { if self.entries[i].0.borrow() == k {
@@ -496,10 +496,10 @@ impl<K, V> StreamMap<K, V> {
/// assert_eq!(map.contains_key(&1), true); /// assert_eq!(map.contains_key(&1), true);
/// assert_eq!(map.contains_key(&2), false); /// assert_eq!(map.contains_key(&2), false);
/// ``` /// ```
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool pub fn contains_key<Q>(&self, k: &Q) -> bool
where where
K: Borrow<Q>, K: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq + ?Sized,
{ {
for i in 0..self.entries.len() { for i in 0..self.entries.len() {
if self.entries[i].0.borrow() == k { if self.entries[i].0.borrow() == k {
+3
View File
@@ -15,18 +15,21 @@ fn require_unpin<T: Unpin>(_t: &T) {}
#[allow(dead_code)] #[allow(dead_code)]
struct Invalid; struct Invalid;
#[allow(unused)]
trait AmbiguousIfSend<A> { trait AmbiguousIfSend<A> {
fn some_item(&self) {} fn some_item(&self) {}
} }
impl<T: ?Sized> AmbiguousIfSend<()> for T {} impl<T: ?Sized> AmbiguousIfSend<()> for T {}
impl<T: ?Sized + Send> AmbiguousIfSend<Invalid> for T {} impl<T: ?Sized + Send> AmbiguousIfSend<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfSync<A> { trait AmbiguousIfSync<A> {
fn some_item(&self) {} fn some_item(&self) {}
} }
impl<T: ?Sized> AmbiguousIfSync<()> for T {} impl<T: ?Sized> AmbiguousIfSync<()> for T {}
impl<T: ?Sized + Sync> AmbiguousIfSync<Invalid> for T {} impl<T: ?Sized + Sync> AmbiguousIfSync<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfUnpin<A> { trait AmbiguousIfUnpin<A> {
fn some_item(&self) {} fn some_item(&self) {}
} }
+1 -1
View File
@@ -1,7 +1,7 @@
#![cfg(all(feature = "time", feature = "sync", feature = "io-util"))] #![cfg(all(feature = "time", feature = "sync", feature = "io-util"))]
use tokio::time::{self, sleep, Duration}; use tokio::time::{self, sleep, Duration};
use tokio_stream::{self, StreamExt}; use tokio_stream::StreamExt;
use tokio_test::*; use tokio_test::*;
use futures::stream; use futures::stream;
@@ -206,7 +206,7 @@ fn move_children_to_parent(node: &mut Inner, parent: &mut Inner) {
for child in std::mem::take(&mut node.children) { for child in std::mem::take(&mut node.children) {
{ {
let mut child_locked = child.inner.lock().unwrap(); let mut child_locked = child.inner.lock().unwrap();
child_locked.parent = node.parent.clone(); child_locked.parent.clone_from(&node.parent);
child_locked.parent_idx = parent.children.len(); child_locked.parent_idx = parent.children.len();
} }
parent.children.push(child); parent.children.push(child);
+1 -1
View File
@@ -23,7 +23,7 @@ use tokio::task::{spawn_local, JoinHandle, LocalSet};
/// ///
/// ``` /// ```
/// use std::rc::Rc; /// use std::rc::Rc;
/// use tokio::{self, task }; /// use tokio::task;
/// use tokio_util::task::LocalPoolHandle; /// use tokio_util::task::LocalPoolHandle;
/// ///
/// #[tokio::main(flavor = "current_thread")] /// #[tokio::main(flavor = "current_thread")]
-1
View File
@@ -442,7 +442,6 @@ feature! {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// use libc;
/// use tokio::fs::OpenOptions; /// use tokio::fs::OpenOptions;
/// use std::io; /// use std::io;
/// ///
+1 -1
View File
@@ -346,7 +346,7 @@ impl ScheduledIo {
match slot { match slot {
Some(existing) => { Some(existing) => {
if !existing.will_wake(cx.waker()) { if !existing.will_wake(cx.waker()) {
*existing = cx.waker().clone(); existing.clone_from(cx.waker());
} }
} }
None => { None => {
+3
View File
@@ -3,7 +3,10 @@ use tokio_test::task;
use std::task::Waker; use std::task::Waker;
#[allow(unused)]
trait AssertSend: Send {} trait AssertSend: Send {}
#[allow(unused)]
trait AssertSync: Sync {} trait AssertSync: Sync {}
impl AssertSend for AtomicWaker {} impl AssertSend for AtomicWaker {}
+7
View File
@@ -14,16 +14,19 @@ use tokio::time::{Duration, Instant};
// The names of these structs behaves better when sorted. // The names of these structs behaves better when sorted.
// Send: Yes, Sync: Yes // Send: Yes, Sync: Yes
#[derive(Clone)] #[derive(Clone)]
#[allow(unused)]
struct YY {} struct YY {}
// Send: Yes, Sync: No // Send: Yes, Sync: No
#[derive(Clone)] #[derive(Clone)]
#[allow(unused)]
struct YN { struct YN {
_value: Cell<u8>, _value: Cell<u8>,
} }
// Send: No, Sync: No // Send: No, Sync: No
#[derive(Clone)] #[derive(Clone)]
#[allow(unused)]
struct NN { struct NN {
_value: Rc<u8>, _value: Rc<u8>,
} }
@@ -52,18 +55,21 @@ fn require_unpin<T: Unpin>(_t: &T) {}
#[allow(dead_code)] #[allow(dead_code)]
struct Invalid; struct Invalid;
#[allow(unused)]
trait AmbiguousIfSend<A> { trait AmbiguousIfSend<A> {
fn some_item(&self) {} fn some_item(&self) {}
} }
impl<T: ?Sized> AmbiguousIfSend<()> for T {} impl<T: ?Sized> AmbiguousIfSend<()> for T {}
impl<T: ?Sized + Send> AmbiguousIfSend<Invalid> for T {} impl<T: ?Sized + Send> AmbiguousIfSend<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfSync<A> { trait AmbiguousIfSync<A> {
fn some_item(&self) {} fn some_item(&self) {}
} }
impl<T: ?Sized> AmbiguousIfSync<()> for T {} impl<T: ?Sized> AmbiguousIfSync<()> for T {}
impl<T: ?Sized + Sync> AmbiguousIfSync<Invalid> for T {} impl<T: ?Sized + Sync> AmbiguousIfSync<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfUnpin<A> { trait AmbiguousIfUnpin<A> {
fn some_item(&self) {} fn some_item(&self) {}
} }
@@ -712,6 +718,7 @@ mod unix_asyncfd {
use super::*; use super::*;
use tokio::io::unix::*; use tokio::io::unix::*;
#[allow(unused)]
struct ImplsFd<T> { struct ImplsFd<T> {
_t: T, _t: T,
} }
+1
View File
@@ -52,6 +52,7 @@ macro_rules! assert_closed {
}; };
} }
#[allow(unused)]
trait AssertSend: Send + Sync {} trait AssertSend: Send + Sync {}
impl AssertSend for broadcast::Sender<i32> {} impl AssertSend for broadcast::Sender<i32> {}
impl AssertSend for broadcast::Receiver<i32> {} impl AssertSend for broadcast::Receiver<i32> {}
+1
View File
@@ -21,6 +21,7 @@ mod support {
pub(crate) mod mpsc_stream; pub(crate) mod mpsc_stream;
} }
#[allow(unused)]
trait AssertSend: Send {} trait AssertSend: Send {}
impl AssertSend for mpsc::Sender<i32> {} impl AssertSend for mpsc::Sender<i32> {}
impl AssertSend for mpsc::Receiver<i32> {} impl AssertSend for mpsc::Receiver<i32> {}
+1
View File
@@ -8,6 +8,7 @@ use tokio::sync::Notify;
use tokio_test::task::spawn; use tokio_test::task::spawn;
use tokio_test::*; use tokio_test::*;
#[allow(unused)]
trait AssertSend: Send + Sync {} trait AssertSend: Send + Sync {}
impl AssertSend for Notify {} impl AssertSend for Notify {}
-1
View File
@@ -2,7 +2,6 @@
#![cfg(feature = "full")] #![cfg(feature = "full")]
use std::mem; use std::mem;
use std::ops::Drop;
use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::atomic::{AtomicU32, Ordering};
use std::time::Duration; use std::time::Duration;
use tokio::runtime; use tokio::runtime;
+3
View File
@@ -17,13 +17,16 @@ use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
#[allow(unused)]
trait AssertSend: Send {} trait AssertSend: Send {}
impl AssertSend for oneshot::Sender<i32> {} impl AssertSend for oneshot::Sender<i32> {}
impl AssertSend for oneshot::Receiver<i32> {} impl AssertSend for oneshot::Receiver<i32> {}
#[allow(unused)]
trait SenderExt { trait SenderExt {
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()>; fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()>;
} }
impl<T> SenderExt for oneshot::Sender<T> { impl<T> SenderExt for oneshot::Sender<T> {
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> { fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> {
tokio::pin! { tokio::pin! {