mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
chore: fix clippy warnings (#4017)
This commit is contained in:
parent
e66217575b
commit
8198ef3881
@ -143,7 +143,7 @@ where
|
|||||||
..
|
..
|
||||||
} = *self;
|
} = *self;
|
||||||
|
|
||||||
let n = ready!(socket.borrow().poll_send_to(cx, &wr, *out_addr))?;
|
let n = ready!(socket.borrow().poll_send_to(cx, wr, *out_addr))?;
|
||||||
|
|
||||||
let wrote_all = n == self.wr.len();
|
let wrote_all = n == self.wr.len();
|
||||||
self.wr.clear();
|
self.wr.clear();
|
||||||
|
@ -11,7 +11,7 @@ use futures_test::task::new_count_waker;
|
|||||||
fn cancel_token() {
|
fn cancel_token() {
|
||||||
let (waker, wake_counter) = new_count_waker();
|
let (waker, wake_counter) = new_count_waker();
|
||||||
let token = CancellationToken::new();
|
let token = CancellationToken::new();
|
||||||
assert_eq!(false, token.is_cancelled());
|
assert!(!token.is_cancelled());
|
||||||
|
|
||||||
let wait_fut = token.cancelled();
|
let wait_fut = token.cancelled();
|
||||||
pin!(wait_fut);
|
pin!(wait_fut);
|
||||||
@ -27,7 +27,7 @@ fn cancel_token() {
|
|||||||
|
|
||||||
token.cancel();
|
token.cancel();
|
||||||
assert_eq!(wake_counter, 1);
|
assert_eq!(wake_counter, 1);
|
||||||
assert_eq!(true, token.is_cancelled());
|
assert!(token.is_cancelled());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Poll::Ready(()),
|
Poll::Ready(()),
|
||||||
@ -64,8 +64,8 @@ fn cancel_child_token_through_parent() {
|
|||||||
|
|
||||||
token.cancel();
|
token.cancel();
|
||||||
assert_eq!(wake_counter, 2);
|
assert_eq!(wake_counter, 2);
|
||||||
assert_eq!(true, token.is_cancelled());
|
assert!(token.is_cancelled());
|
||||||
assert_eq!(true, child_token.is_cancelled());
|
assert!(child_token.is_cancelled());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Poll::Ready(()),
|
Poll::Ready(()),
|
||||||
@ -101,8 +101,8 @@ fn cancel_child_token_without_parent() {
|
|||||||
|
|
||||||
child_token_1.cancel();
|
child_token_1.cancel();
|
||||||
assert_eq!(wake_counter, 1);
|
assert_eq!(wake_counter, 1);
|
||||||
assert_eq!(false, token.is_cancelled());
|
assert!(!token.is_cancelled());
|
||||||
assert_eq!(true, child_token_1.is_cancelled());
|
assert!(child_token_1.is_cancelled());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Poll::Ready(()),
|
Poll::Ready(()),
|
||||||
@ -128,8 +128,8 @@ fn cancel_child_token_without_parent() {
|
|||||||
|
|
||||||
token.cancel();
|
token.cancel();
|
||||||
assert_eq!(wake_counter, 3);
|
assert_eq!(wake_counter, 3);
|
||||||
assert_eq!(true, token.is_cancelled());
|
assert!(token.is_cancelled());
|
||||||
assert_eq!(true, child_token_2.is_cancelled());
|
assert!(child_token_2.is_cancelled());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Poll::Ready(()),
|
Poll::Ready(()),
|
||||||
|
@ -63,7 +63,7 @@ impl<T> ReadHalf<T> {
|
|||||||
/// Checks if this `ReadHalf` and some `WriteHalf` were split from the same
|
/// Checks if this `ReadHalf` and some `WriteHalf` were split from the same
|
||||||
/// stream.
|
/// stream.
|
||||||
pub fn is_pair_of(&self, other: &WriteHalf<T>) -> bool {
|
pub fn is_pair_of(&self, other: &WriteHalf<T>) -> bool {
|
||||||
other.is_pair_of(&self)
|
other.is_pair_of(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reunites with a previously split `WriteHalf`.
|
/// Reunites with a previously split `WriteHalf`.
|
||||||
|
@ -87,7 +87,7 @@ impl<T> OrphanQueueImpl<T> {
|
|||||||
// means that the signal driver isn't running, in
|
// means that the signal driver isn't running, in
|
||||||
// which case there isn't anything we can
|
// which case there isn't anything we can
|
||||||
// register/initialize here, so we can try again later
|
// register/initialize here, so we can try again later
|
||||||
if let Ok(sigchild) = signal_with_handle(SignalKind::child(), &handle) {
|
if let Ok(sigchild) = signal_with_handle(SignalKind::child(), handle) {
|
||||||
*sigchild_guard = Some(sigchild);
|
*sigchild_guard = Some(sigchild);
|
||||||
drain_orphan_queue(queue);
|
drain_orphan_queue(queue);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ impl<P: Park> BasicScheduler<P> {
|
|||||||
|
|
||||||
Some(InnerGuard {
|
Some(InnerGuard {
|
||||||
inner: Some(inner),
|
inner: Some(inner),
|
||||||
basic_scheduler: &self,
|
basic_scheduler: self,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ impl Handle {
|
|||||||
let _ = name;
|
let _ = name;
|
||||||
|
|
||||||
let (task, handle) = task::unowned(fut, NoopSchedule);
|
let (task, handle) = task::unowned(fut, NoopSchedule);
|
||||||
let _ = self.blocking_spawner.spawn(task, &self);
|
let _ = self.blocking_spawner.spawn(task, self);
|
||||||
handle
|
handle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ where
|
|||||||
stage.store_output(output);
|
stage.store_output(output);
|
||||||
|
|
||||||
// Transition to `Complete`, notifying the `JoinHandle` if necessary.
|
// Transition to `Complete`, notifying the `JoinHandle` if necessary.
|
||||||
transition_to_complete(self.header(), stage, &self.trailer());
|
transition_to_complete(self.header(), stage, self.trailer());
|
||||||
} else {
|
} else {
|
||||||
drop(output);
|
drop(output);
|
||||||
}
|
}
|
||||||
|
@ -240,17 +240,17 @@ mod tests {
|
|||||||
let registry = Registry::new(vec![EventInfo::default(), EventInfo::default()]);
|
let registry = Registry::new(vec![EventInfo::default(), EventInfo::default()]);
|
||||||
|
|
||||||
registry.record_event(0);
|
registry.record_event(0);
|
||||||
assert_eq!(false, registry.broadcast());
|
assert!(!registry.broadcast());
|
||||||
|
|
||||||
let first = registry.register_listener(0);
|
let first = registry.register_listener(0);
|
||||||
let second = registry.register_listener(1);
|
let second = registry.register_listener(1);
|
||||||
|
|
||||||
registry.record_event(0);
|
registry.record_event(0);
|
||||||
assert_eq!(true, registry.broadcast());
|
assert!(registry.broadcast());
|
||||||
|
|
||||||
drop(first);
|
drop(first);
|
||||||
registry.record_event(0);
|
registry.record_event(0);
|
||||||
assert_eq!(false, registry.broadcast());
|
assert!(!registry.broadcast());
|
||||||
|
|
||||||
drop(second);
|
drop(second);
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ impl<'a> Acquire<'a> {
|
|||||||
let this = self.get_unchecked_mut();
|
let this = self.get_unchecked_mut();
|
||||||
(
|
(
|
||||||
Pin::new_unchecked(&mut this.node),
|
Pin::new_unchecked(&mut this.node),
|
||||||
&this.semaphore,
|
this.semaphore,
|
||||||
this.num_permits,
|
this.num_permits,
|
||||||
&mut this.queued,
|
&mut this.queued,
|
||||||
)
|
)
|
||||||
|
@ -528,7 +528,7 @@ impl Notified<'_> {
|
|||||||
is_unpin::<AtomicUsize>();
|
is_unpin::<AtomicUsize>();
|
||||||
|
|
||||||
let me = self.get_unchecked_mut();
|
let me = self.get_unchecked_mut();
|
||||||
(&me.notify, &mut me.state, &me.waiter)
|
(me.notify, &mut me.state, &me.waiter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ impl Semaphore {
|
|||||||
pub async fn acquire(&self) -> Result<SemaphorePermit<'_>, AcquireError> {
|
pub async fn acquire(&self) -> Result<SemaphorePermit<'_>, AcquireError> {
|
||||||
self.ll_sem.acquire(1).await?;
|
self.ll_sem.acquire(1).await?;
|
||||||
Ok(SemaphorePermit {
|
Ok(SemaphorePermit {
|
||||||
sem: &self,
|
sem: self,
|
||||||
permits: 1,
|
permits: 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ impl Semaphore {
|
|||||||
pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> {
|
pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> {
|
||||||
self.ll_sem.acquire(n).await?;
|
self.ll_sem.acquire(n).await?;
|
||||||
Ok(SemaphorePermit {
|
Ok(SemaphorePermit {
|
||||||
sem: &self,
|
sem: self,
|
||||||
permits: n,
|
permits: n,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@ impl task::Schedule for Arc<Shared> {
|
|||||||
CURRENT.with(|maybe_cx| {
|
CURRENT.with(|maybe_cx| {
|
||||||
let cx = maybe_cx.expect("scheduler context missing");
|
let cx = maybe_cx.expect("scheduler context missing");
|
||||||
assert!(cx.shared.ptr_eq(self));
|
assert!(cx.shared.ptr_eq(self));
|
||||||
cx.tasks.borrow_mut().owned.remove(&task)
|
cx.tasks.borrow_mut().owned.remove(task)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ impl<T: 'static> LocalKey<T> {
|
|||||||
F: Future,
|
F: Future,
|
||||||
{
|
{
|
||||||
TaskLocalFuture {
|
TaskLocalFuture {
|
||||||
local: &self,
|
local: self,
|
||||||
slot: Some(value),
|
slot: Some(value),
|
||||||
future: f,
|
future: f,
|
||||||
_pinned: PhantomPinned,
|
_pinned: PhantomPinned,
|
||||||
@ -150,7 +150,7 @@ impl<T: 'static> LocalKey<T> {
|
|||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
{
|
{
|
||||||
let scope = TaskLocalFuture {
|
let scope = TaskLocalFuture {
|
||||||
local: &self,
|
local: self,
|
||||||
slot: Some(value),
|
slot: Some(value),
|
||||||
future: (),
|
future: (),
|
||||||
_pinned: PhantomPinned,
|
_pinned: PhantomPinned,
|
||||||
|
@ -50,10 +50,10 @@ fn is_send_and_sync() {
|
|||||||
fn split_stream_id() {
|
fn split_stream_id() {
|
||||||
let (r1, w1) = split(RW);
|
let (r1, w1) = split(RW);
|
||||||
let (r2, w2) = split(RW);
|
let (r2, w2) = split(RW);
|
||||||
assert_eq!(r1.is_pair_of(&w1), true);
|
assert!(r1.is_pair_of(&w1));
|
||||||
assert_eq!(r1.is_pair_of(&w2), false);
|
assert!(!r1.is_pair_of(&w2));
|
||||||
assert_eq!(r2.is_pair_of(&w2), true);
|
assert!(r2.is_pair_of(&w2));
|
||||||
assert_eq!(r2.is_pair_of(&w1), false);
|
assert!(!r2.is_pair_of(&w1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -52,7 +52,7 @@ async fn write_all_buf() {
|
|||||||
assert_eq!(wr.buf, b"helloworld"[..]);
|
assert_eq!(wr.buf, b"helloworld"[..]);
|
||||||
// expect 4 writes, [hell],[o],[worl],[d]
|
// expect 4 writes, [hell],[o],[worl],[d]
|
||||||
assert_eq!(wr.cnt, 4);
|
assert_eq!(wr.cnt, 4);
|
||||||
assert_eq!(buf.has_remaining(), false);
|
assert!(!buf.has_remaining());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@ -139,12 +139,12 @@ fn try_lock() {
|
|||||||
let m: Mutex<usize> = Mutex::new(0);
|
let m: Mutex<usize> = Mutex::new(0);
|
||||||
{
|
{
|
||||||
let g1 = m.try_lock();
|
let g1 = m.try_lock();
|
||||||
assert_eq!(g1.is_ok(), true);
|
assert!(g1.is_ok());
|
||||||
let g2 = m.try_lock();
|
let g2 = m.try_lock();
|
||||||
assert_eq!(g2.is_ok(), false);
|
assert!(!g2.is_ok());
|
||||||
}
|
}
|
||||||
let g3 = m.try_lock();
|
let g3 = m.try_lock();
|
||||||
assert_eq!(g3.is_ok(), true);
|
assert!(g3.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@ -106,12 +106,12 @@ fn try_lock_owned() {
|
|||||||
let m: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
|
let m: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
|
||||||
{
|
{
|
||||||
let g1 = m.clone().try_lock_owned();
|
let g1 = m.clone().try_lock_owned();
|
||||||
assert_eq!(g1.is_ok(), true);
|
assert!(g1.is_ok());
|
||||||
let g2 = m.clone().try_lock_owned();
|
let g2 = m.clone().try_lock_owned();
|
||||||
assert_eq!(g2.is_ok(), false);
|
assert!(!g2.is_ok());
|
||||||
}
|
}
|
||||||
let g3 = m.try_lock_owned();
|
let g3 = m.try_lock_owned();
|
||||||
assert_eq!(g3.is_ok(), true);
|
assert!(g3.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user