From 67a5700d6a03ae813cdc384d8fcc3d04f2695db6 Mon Sep 17 00:00:00 2001 From: conorbros Date: Tue, 5 Jul 2022 17:00:59 +1000 Subject: [PATCH] fix clippy lints --- futures-util/benches/select.rs | 5 ++--- futures-util/src/future/future/shared.rs | 4 +++- futures-util/src/io/write_all_vectored.rs | 6 +++--- futures-util/src/lock/mutex.rs | 5 ++++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/futures-util/benches/select.rs b/futures-util/benches/select.rs index 5410a95299..a8eb7f7ee8 100644 --- a/futures-util/benches/select.rs +++ b/futures-util/benches/select.rs @@ -19,7 +19,7 @@ fn select_streams(b: &mut Bencher) { let stream6 = repeat(6).take(STREAM_COUNT); let stream7 = repeat(7).take(STREAM_COUNT); let count = block_on(async { - let count = select( + select( stream1, select( stream2, @@ -27,8 +27,7 @@ fn select_streams(b: &mut Bencher) { ), ) .count() - .await; - count + .await }); assert_eq!(count, STREAM_COUNT * 7); }); diff --git a/futures-util/src/future/future/shared.rs b/futures-util/src/future/future/shared.rs index cc900ba5b6..dd7c2f5067 100644 --- a/futures-util/src/future/future/shared.rs +++ b/futures-util/src/future/future/shared.rs @@ -174,7 +174,9 @@ where fn record_waker(&self, waker_key: &mut usize, cx: &mut Context<'_>) { let mut wakers_guard = self.notifier.wakers.lock().unwrap(); - let wakers = match wakers_guard.as_mut() { + let wakers_mut = wakers_guard.as_mut(); + + let wakers = match wakers_mut { Some(wakers) => wakers, None => return, }; diff --git a/futures-util/src/io/write_all_vectored.rs b/futures-util/src/io/write_all_vectored.rs index c3139f25c0..09b220a8dd 100644 --- a/futures-util/src/io/write_all_vectored.rs +++ b/futures-util/src/io/write_all_vectored.rs @@ -181,13 +181,13 @@ mod tests { for (mut input, wanted) in tests { let mut dst = test_writer(2, 2); { - let mut future = dst.write_all_vectored(&mut *input); + let mut future = dst.write_all_vectored(&mut input); match Pin::new(&mut future).poll(&mut cx) { Poll::Ready(Ok(())) => {} other => panic!("unexpected result polling future: {:?}", other), } } - assert_eq!(&*dst.written, &*wanted); + assert_eq!(&*dst.written, wanted); } } @@ -207,7 +207,7 @@ mod tests { let data = vec![1, 2, 3, 4]; { let mut slices = WrapVec(data.chunks(2).map(IoSlice::new).collect()); - let mut future = dst.write_all_vectored(&mut *slices.0); + let mut future = dst.write_all_vectored(&mut slices.0); match Pin::new(&mut future).poll(&mut cx) { Poll::Ready(Ok(())) => {} other => panic!("unexpected result polling future: {:?}", other), diff --git a/futures-util/src/lock/mutex.rs b/futures-util/src/lock/mutex.rs index 335ad14273..be82720f6b 100644 --- a/futures-util/src/lock/mutex.rs +++ b/futures-util/src/lock/mutex.rs @@ -162,7 +162,10 @@ impl Mutex { fn remove_waker(&self, wait_key: usize, wake_another: bool) { if wait_key != WAIT_KEY_NONE { let mut waiters = self.waiters.lock().unwrap(); - match waiters.remove(wait_key) { + + let removed_waker = waiters.remove(wait_key); + + match removed_waker { Waiter::Waiting(_) => {} Waiter::Woken => { // We were awoken, but then dropped before we could