Skip to content

Commit

Permalink
chore: fix clippy warnings (#4017)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkTed authored Aug 3, 2021
1 parent e662175 commit 8198ef3
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion tokio-util/src/udp/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions tokio-util/tests/sync_cancellation_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(()),
Expand Down Expand Up @@ -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(()),
Expand Down Expand Up @@ -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(()),
Expand All @@ -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(()),
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/process/unix/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/basic_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<P: Park> BasicScheduler<P> {

Some(InnerGuard {
inner: Some(inner),
basic_scheduler: &self,
basic_scheduler: self,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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 @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions tokio/src/signal/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/batch_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -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,
})
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/task/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
4 changes: 2 additions & 2 deletions tokio/src/task/task_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<T: 'static> LocalKey<T> {
F: Future,
{
TaskLocalFuture {
local: &self,
local: self,
slot: Some(value),
future: f,
_pinned: PhantomPinned,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tokio/tests/io_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_write_all_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/sync_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/sync_mutex_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 8198ef3

Please sign in to comment.