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,
}
thread_local!(static LAST: RefCell<LastRenderedNow> = RefCell::new(LastRenderedNow {
thread_local!(static LAST: RefCell<LastRenderedNow> = const { RefCell::new(LastRenderedNow {
bytes: [0; 128],
amt: 0,
unix_date: 0,
}));
}) });
impl fmt::Display for Now {
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_none());
/// ```
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
for i in 0..self.entries.len() {
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(&2), false);
/// ```
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
for i in 0..self.entries.len() {
if self.entries[i].0.borrow() == k {
+3
View File
@@ -15,18 +15,21 @@ fn require_unpin<T: Unpin>(_t: &T) {}
#[allow(dead_code)]
struct Invalid;
#[allow(unused)]
trait AmbiguousIfSend<A> {
fn some_item(&self) {}
}
impl<T: ?Sized> AmbiguousIfSend<()> for T {}
impl<T: ?Sized + Send> AmbiguousIfSend<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfSync<A> {
fn some_item(&self) {}
}
impl<T: ?Sized> AmbiguousIfSync<()> for T {}
impl<T: ?Sized + Sync> AmbiguousIfSync<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfUnpin<A> {
fn some_item(&self) {}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#![cfg(all(feature = "time", feature = "sync", feature = "io-util"))]
use tokio::time::{self, sleep, Duration};
use tokio_stream::{self, StreamExt};
use tokio_stream::StreamExt;
use tokio_test::*;
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) {
{
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();
}
parent.children.push(child);
+1 -1
View File
@@ -23,7 +23,7 @@ use tokio::task::{spawn_local, JoinHandle, LocalSet};
///
/// ```
/// use std::rc::Rc;
/// use tokio::{self, task };
/// use tokio::task;
/// use tokio_util::task::LocalPoolHandle;
///
/// #[tokio::main(flavor = "current_thread")]
-1
View File
@@ -442,7 +442,6 @@ feature! {
/// # Examples
///
/// ```no_run
/// use libc;
/// use tokio::fs::OpenOptions;
/// use std::io;
///
+1 -1
View File
@@ -346,7 +346,7 @@ impl ScheduledIo {
match slot {
Some(existing) => {
if !existing.will_wake(cx.waker()) {
*existing = cx.waker().clone();
existing.clone_from(cx.waker());
}
}
None => {
+3
View File
@@ -3,7 +3,10 @@ use tokio_test::task;
use std::task::Waker;
#[allow(unused)]
trait AssertSend: Send {}
#[allow(unused)]
trait AssertSync: Sync {}
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.
// Send: Yes, Sync: Yes
#[derive(Clone)]
#[allow(unused)]
struct YY {}
// Send: Yes, Sync: No
#[derive(Clone)]
#[allow(unused)]
struct YN {
_value: Cell<u8>,
}
// Send: No, Sync: No
#[derive(Clone)]
#[allow(unused)]
struct NN {
_value: Rc<u8>,
}
@@ -52,18 +55,21 @@ fn require_unpin<T: Unpin>(_t: &T) {}
#[allow(dead_code)]
struct Invalid;
#[allow(unused)]
trait AmbiguousIfSend<A> {
fn some_item(&self) {}
}
impl<T: ?Sized> AmbiguousIfSend<()> for T {}
impl<T: ?Sized + Send> AmbiguousIfSend<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfSync<A> {
fn some_item(&self) {}
}
impl<T: ?Sized> AmbiguousIfSync<()> for T {}
impl<T: ?Sized + Sync> AmbiguousIfSync<Invalid> for T {}
#[allow(unused)]
trait AmbiguousIfUnpin<A> {
fn some_item(&self) {}
}
@@ -712,6 +718,7 @@ mod unix_asyncfd {
use super::*;
use tokio::io::unix::*;
#[allow(unused)]
struct ImplsFd<T> {
_t: T,
}
+1
View File
@@ -52,6 +52,7 @@ macro_rules! assert_closed {
};
}
#[allow(unused)]
trait AssertSend: Send + Sync {}
impl AssertSend for broadcast::Sender<i32> {}
impl AssertSend for broadcast::Receiver<i32> {}
+1
View File
@@ -21,6 +21,7 @@ mod support {
pub(crate) mod mpsc_stream;
}
#[allow(unused)]
trait AssertSend: Send {}
impl AssertSend for mpsc::Sender<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::*;
#[allow(unused)]
trait AssertSend: Send + Sync {}
impl AssertSend for Notify {}
-1
View File
@@ -2,7 +2,6 @@
#![cfg(feature = "full")]
use std::mem;
use std::ops::Drop;
use std::sync::atomic::{AtomicU32, Ordering};
use std::time::Duration;
use tokio::runtime;
+3
View File
@@ -17,13 +17,16 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[allow(unused)]
trait AssertSend: Send {}
impl AssertSend for oneshot::Sender<i32> {}
impl AssertSend for oneshot::Receiver<i32> {}
#[allow(unused)]
trait SenderExt {
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()>;
}
impl<T> SenderExt for oneshot::Sender<T> {
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> {
tokio::pin! {