chore: fix clippy warnings (#4017)

This commit is contained in:
LinkTed 2021-08-03 11:50:40 +03:00 committed by GitHub
parent e66217575b
commit 8198ef3881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 35 additions and 35 deletions

View File

@ -143,7 +143,7 @@ where
..
} = *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();
self.wr.clear();

View File

@ -11,7 +11,7 @@ use futures_test::task::new_count_waker;
fn cancel_token() {
let (waker, wake_counter) = new_count_waker();
let token = CancellationToken::new();
assert_eq!(false, token.is_cancelled());
assert!(!token.is_cancelled());
let wait_fut = token.cancelled();
pin!(wait_fut);
@ -27,7 +27,7 @@ fn cancel_token() {
token.cancel();
assert_eq!(wake_counter, 1);
assert_eq!(true, token.is_cancelled());
assert!(token.is_cancelled());
assert_eq!(
Poll::Ready(()),
@ -64,8 +64,8 @@ fn cancel_child_token_through_parent() {
token.cancel();
assert_eq!(wake_counter, 2);
assert_eq!(true, token.is_cancelled());
assert_eq!(true, child_token.is_cancelled());
assert!(token.is_cancelled());
assert!(child_token.is_cancelled());
assert_eq!(
Poll::Ready(()),
@ -101,8 +101,8 @@ fn cancel_child_token_without_parent() {
child_token_1.cancel();
assert_eq!(wake_counter, 1);
assert_eq!(false, token.is_cancelled());
assert_eq!(true, child_token_1.is_cancelled());
assert!(!token.is_cancelled());
assert!(child_token_1.is_cancelled());
assert_eq!(
Poll::Ready(()),
@ -128,8 +128,8 @@ fn cancel_child_token_without_parent() {
token.cancel();
assert_eq!(wake_counter, 3);
assert_eq!(true, token.is_cancelled());
assert_eq!(true, child_token_2.is_cancelled());
assert!(token.is_cancelled());
assert!(child_token_2.is_cancelled());
assert_eq!(
Poll::Ready(()),

View File

@ -63,7 +63,7 @@ impl<T> ReadHalf<T> {
/// Checks if this `ReadHalf` and some `WriteHalf` were split from the same
/// stream.
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`.

View File

@ -87,7 +87,7 @@ impl<T> OrphanQueueImpl<T> {
// means that the signal driver isn't running, in
// which case there isn't anything we can
// 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);
drain_orphan_queue(queue);
}

View File

@ -186,7 +186,7 @@ impl<P: Park> BasicScheduler<P> {
Some(InnerGuard {
inner: Some(inner),
basic_scheduler: &self,
basic_scheduler: self,
})
}
}

View File

@ -214,7 +214,7 @@ impl Handle {
let _ = name;
let (task, handle) = task::unowned(fut, NoopSchedule);
let _ = self.blocking_spawner.spawn(task, &self);
let _ = self.blocking_spawner.spawn(task, self);
handle
}

View File

@ -207,7 +207,7 @@ where
stage.store_output(output);
// 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 {
drop(output);
}

View File

@ -240,17 +240,17 @@ mod tests {
let registry = Registry::new(vec![EventInfo::default(), EventInfo::default()]);
registry.record_event(0);
assert_eq!(false, registry.broadcast());
assert!(!registry.broadcast());
let first = registry.register_listener(0);
let second = registry.register_listener(1);
registry.record_event(0);
assert_eq!(true, registry.broadcast());
assert!(registry.broadcast());
drop(first);
registry.record_event(0);
assert_eq!(false, registry.broadcast());
assert!(!registry.broadcast());
drop(second);
}

View File

@ -478,7 +478,7 @@ impl<'a> Acquire<'a> {
let this = self.get_unchecked_mut();
(
Pin::new_unchecked(&mut this.node),
&this.semaphore,
this.semaphore,
this.num_permits,
&mut this.queued,
)

View File

@ -528,7 +528,7 @@ impl Notified<'_> {
is_unpin::<AtomicUsize>();
let me = self.get_unchecked_mut();
(&me.notify, &mut me.state, &me.waiter)
(me.notify, &mut me.state, &me.waiter)
}
}
}

View File

@ -193,7 +193,7 @@ impl Semaphore {
pub async fn acquire(&self) -> Result<SemaphorePermit<'_>, AcquireError> {
self.ll_sem.acquire(1).await?;
Ok(SemaphorePermit {
sem: &self,
sem: self,
permits: 1,
})
}
@ -229,7 +229,7 @@ impl Semaphore {
pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> {
self.ll_sem.acquire(n).await?;
Ok(SemaphorePermit {
sem: &self,
sem: self,
permits: n,
})
}

View File

@ -716,7 +716,7 @@ impl task::Schedule for Arc<Shared> {
CURRENT.with(|maybe_cx| {
let cx = maybe_cx.expect("scheduler context missing");
assert!(cx.shared.ptr_eq(self));
cx.tasks.borrow_mut().owned.remove(&task)
cx.tasks.borrow_mut().owned.remove(task)
})
}

View File

@ -121,7 +121,7 @@ impl<T: 'static> LocalKey<T> {
F: Future,
{
TaskLocalFuture {
local: &self,
local: self,
slot: Some(value),
future: f,
_pinned: PhantomPinned,
@ -150,7 +150,7 @@ impl<T: 'static> LocalKey<T> {
F: FnOnce() -> R,
{
let scope = TaskLocalFuture {
local: &self,
local: self,
slot: Some(value),
future: (),
_pinned: PhantomPinned,

View File

@ -50,10 +50,10 @@ fn is_send_and_sync() {
fn split_stream_id() {
let (r1, w1) = split(RW);
let (r2, w2) = split(RW);
assert_eq!(r1.is_pair_of(&w1), true);
assert_eq!(r1.is_pair_of(&w2), false);
assert_eq!(r2.is_pair_of(&w2), true);
assert_eq!(r2.is_pair_of(&w1), false);
assert!(r1.is_pair_of(&w1));
assert!(!r1.is_pair_of(&w2));
assert!(r2.is_pair_of(&w2));
assert!(!r2.is_pair_of(&w1));
}
#[test]

View File

@ -52,7 +52,7 @@ async fn write_all_buf() {
assert_eq!(wr.buf, b"helloworld"[..]);
// expect 4 writes, [hell],[o],[worl],[d]
assert_eq!(wr.cnt, 4);
assert_eq!(buf.has_remaining(), false);
assert!(!buf.has_remaining());
}
#[tokio::test]

View File

@ -139,12 +139,12 @@ fn try_lock() {
let m: Mutex<usize> = Mutex::new(0);
{
let g1 = m.try_lock();
assert_eq!(g1.is_ok(), true);
assert!(g1.is_ok());
let g2 = m.try_lock();
assert_eq!(g2.is_ok(), false);
assert!(!g2.is_ok());
}
let g3 = m.try_lock();
assert_eq!(g3.is_ok(), true);
assert!(g3.is_ok());
}
#[tokio::test]

View File

@ -106,12 +106,12 @@ fn try_lock_owned() {
let m: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
{
let g1 = m.clone().try_lock_owned();
assert_eq!(g1.is_ok(), true);
assert!(g1.is_ok());
let g2 = m.clone().try_lock_owned();
assert_eq!(g2.is_ok(), false);
assert!(!g2.is_ok());
}
let g3 = m.try_lock_owned();
assert_eq!(g3.is_ok(), true);
assert!(g3.is_ok());
}
#[tokio::test]