From 5dd3497107e97b6341eb519f080fd13907f26855 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 9 Oct 2024 10:18:38 +0300 Subject: [PATCH] chore: `cargo +nightly clippy --fix` --- quinn-proto/src/connection/datagrams.rs | 2 +- quinn-proto/src/connection/streams/mod.rs | 4 +++- quinn-proto/src/connection/streams/recv.rs | 2 +- quinn-proto/src/connection/streams/send.rs | 4 ++-- quinn-proto/src/frame.rs | 2 +- quinn-proto/src/range_set/btree_range_set.rs | 8 ++++---- quinn-udp/src/cmsg/mod.rs | 2 +- quinn/src/endpoint.rs | 2 +- quinn/src/mutex.rs | 4 ++-- quinn/src/recv_stream.rs | 8 ++++---- quinn/src/send_stream.rs | 10 +++++----- 11 files changed, 25 insertions(+), 23 deletions(-) diff --git a/quinn-proto/src/connection/datagrams.rs b/quinn-proto/src/connection/datagrams.rs index 45454e107..c8d1091fa 100644 --- a/quinn-proto/src/connection/datagrams.rs +++ b/quinn-proto/src/connection/datagrams.rs @@ -15,7 +15,7 @@ pub struct Datagrams<'a> { pub(super) conn: &'a mut Connection, } -impl<'a> Datagrams<'a> { +impl Datagrams<'_> { /// Queue an unreliable, unordered datagram for immediate transmission /// /// If `drop` is true, previously queued datagrams which are still unsent may be discarded to diff --git a/quinn-proto/src/connection/streams/mod.rs b/quinn-proto/src/connection/streams/mod.rs index 62036c083..9a4b62c3a 100644 --- a/quinn-proto/src/connection/streams/mod.rs +++ b/quinn-proto/src/connection/streams/mod.rs @@ -32,6 +32,7 @@ pub struct Streams<'a> { pub(super) conn_state: &'a super::State, } +#[allow(clippy::needless_lifetimes)] // Needed for cfg(fuzzing) impl<'a> Streams<'a> { #[cfg(fuzzing)] pub fn new(state: &'a mut StreamsState, conn_state: &'a super::State) -> Self { @@ -106,7 +107,7 @@ pub struct RecvStream<'a> { pub(super) pending: &'a mut Retransmits, } -impl<'a> RecvStream<'a> { +impl RecvStream<'_> { /// Read from the given recv stream /// /// `max_length` limits the maximum size of the returned `Bytes` value; passing `usize::MAX` @@ -198,6 +199,7 @@ pub struct SendStream<'a> { pub(super) conn_state: &'a super::State, } +#[allow(clippy::needless_lifetimes)] // Needed for cfg(fuzzing) impl<'a> SendStream<'a> { #[cfg(fuzzing)] pub fn new( diff --git a/quinn-proto/src/connection/streams/recv.rs b/quinn-proto/src/connection/streams/recv.rs index b649eb492..a8dc79bbc 100644 --- a/quinn-proto/src/connection/streams/recv.rs +++ b/quinn-proto/src/connection/streams/recv.rs @@ -379,7 +379,7 @@ impl<'a> Chunks<'a> { } } -impl<'a> Drop for Chunks<'a> { +impl Drop for Chunks<'_> { fn drop(&mut self) { let _ = self.finalize_inner(); } diff --git a/quinn-proto/src/connection/streams/send.rs b/quinn-proto/src/connection/streams/send.rs index 060aaf54c..f3800fad8 100644 --- a/quinn-proto/src/connection/streams/send.rs +++ b/quinn-proto/src/connection/streams/send.rs @@ -163,7 +163,7 @@ impl<'a> BytesArray<'a> { } } -impl<'a> BytesSource for BytesArray<'a> { +impl BytesSource for BytesArray<'_> { fn pop_chunk(&mut self, limit: usize) -> (Bytes, usize) { // The loop exists to skip empty chunks while still marking them as // consumed @@ -208,7 +208,7 @@ impl<'a> ByteSlice<'a> { } } -impl<'a> BytesSource for ByteSlice<'a> { +impl BytesSource for ByteSlice<'_> { fn pop_chunk(&mut self, limit: usize) -> (Bytes, usize) { let limit = limit.min(self.data.len()); if limit == 0 { diff --git a/quinn-proto/src/frame.rs b/quinn-proto/src/frame.rs index d58cb36e5..60b17eb78 100644 --- a/quinn-proto/src/frame.rs +++ b/quinn-proto/src/frame.rs @@ -803,7 +803,7 @@ impl<'a> AckIter<'a> { } } -impl<'a> Iterator for AckIter<'a> { +impl Iterator for AckIter<'_> { type Item = RangeInclusive; fn next(&mut self) -> Option> { if !self.data.has_remaining() { diff --git a/quinn-proto/src/range_set/btree_range_set.rs b/quinn-proto/src/range_set/btree_range_set.rs index 948e8bd53..85a2c538a 100644 --- a/quinn-proto/src/range_set/btree_range_set.rs +++ b/quinn-proto/src/range_set/btree_range_set.rs @@ -212,7 +212,7 @@ impl RangeSet { pub struct Iter<'a>(btree_map::Iter<'a, u64, u64>); -impl<'a> Iterator for Iter<'a> { +impl Iterator for Iter<'_> { type Item = Range; fn next(&mut self) -> Option> { let (&start, &end) = self.0.next()?; @@ -220,7 +220,7 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> DoubleEndedIterator for Iter<'a> { +impl DoubleEndedIterator for Iter<'_> { fn next_back(&mut self) -> Option> { let (&start, &end) = self.0.next_back()?; Some(start..end) @@ -241,7 +241,7 @@ pub struct EltIter<'a> { end: u64, } -impl<'a> Iterator for EltIter<'a> { +impl Iterator for EltIter<'_> { type Item = u64; fn next(&mut self) -> Option { if self.next == self.end { @@ -255,7 +255,7 @@ impl<'a> Iterator for EltIter<'a> { } } -impl<'a> DoubleEndedIterator for EltIter<'a> { +impl DoubleEndedIterator for EltIter<'_> { fn next_back(&mut self) -> Option { if self.next == self.end { let (&start, &end) = self.inner.next_back()?; diff --git a/quinn-udp/src/cmsg/mod.rs b/quinn-udp/src/cmsg/mod.rs index 599c7e281..4a1c90e22 100644 --- a/quinn-udp/src/cmsg/mod.rs +++ b/quinn-udp/src/cmsg/mod.rs @@ -72,7 +72,7 @@ impl<'a, M: MsgHdr> Encoder<'a, M> { // Statically guarantees that the encoding operation is "finished" before the control buffer is read // by `sendmsg` like API. -impl<'a, M: MsgHdr> Drop for Encoder<'a, M> { +impl Drop for Encoder<'_, M> { fn drop(&mut self) { self.hdr.set_control_len(self.len as _); } diff --git a/quinn/src/endpoint.rs b/quinn/src/endpoint.rs index 7dd203570..2563f3771 100644 --- a/quinn/src/endpoint.rs +++ b/quinn/src/endpoint.rs @@ -633,7 +633,7 @@ pin_project! { } } -impl<'a> Future for Accept<'a> { +impl Future for Accept<'_> { type Output = Option; fn poll(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll { let mut this = self.project(); diff --git a/quinn/src/mutex.rs b/quinn/src/mutex.rs index c110bcec8..a2a1fe277 100644 --- a/quinn/src/mutex.rs +++ b/quinn/src/mutex.rs @@ -146,7 +146,7 @@ mod non_tracking { guard: std::sync::MutexGuard<'a, T>, } - impl<'a, T> Deref for MutexGuard<'a, T> { + impl Deref for MutexGuard<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -154,7 +154,7 @@ mod non_tracking { } } - impl<'a, T> DerefMut for MutexGuard<'a, T> { + impl DerefMut for MutexGuard<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { self.guard.deref_mut() } diff --git a/quinn/src/recv_stream.rs b/quinn/src/recv_stream.rs index be2b64324..ee22bb231 100644 --- a/quinn/src/recv_stream.rs +++ b/quinn/src/recv_stream.rs @@ -603,7 +603,7 @@ struct Read<'a> { buf: ReadBuf<'a>, } -impl<'a> Future for Read<'a> { +impl Future for Read<'_> { type Output = Result, ReadError>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { @@ -625,7 +625,7 @@ struct ReadExact<'a> { buf: ReadBuf<'a>, } -impl<'a> Future for ReadExact<'a> { +impl Future for ReadExact<'_> { type Output = Result<(), ReadExactError>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut(); @@ -663,7 +663,7 @@ struct ReadChunk<'a> { ordered: bool, } -impl<'a> Future for ReadChunk<'a> { +impl Future for ReadChunk<'_> { type Output = Result, ReadError>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { let (max_length, ordered) = (self.max_length, self.ordered); @@ -680,7 +680,7 @@ struct ReadChunks<'a> { bufs: &'a mut [Bytes], } -impl<'a> Future for ReadChunks<'a> { +impl Future for ReadChunks<'_> { type Output = Result, ReadError>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut(); diff --git a/quinn/src/send_stream.rs b/quinn/src/send_stream.rs index 839fcbf66..600507881 100644 --- a/quinn/src/send_stream.rs +++ b/quinn/src/send_stream.rs @@ -327,7 +327,7 @@ struct Write<'a> { buf: &'a [u8], } -impl<'a> Future for Write<'a> { +impl Future for Write<'_> { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut(); @@ -345,7 +345,7 @@ struct WriteAll<'a> { buf: &'a [u8], } -impl<'a> Future for WriteAll<'a> { +impl Future for WriteAll<'_> { type Output = Result<(), WriteError>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut(); @@ -369,7 +369,7 @@ struct WriteChunks<'a> { bufs: &'a mut [Bytes], } -impl<'a> Future for WriteChunks<'a> { +impl Future for WriteChunks<'_> { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut(); @@ -387,7 +387,7 @@ struct WriteChunk<'a> { buf: [Bytes; 1], } -impl<'a> Future for WriteChunk<'a> { +impl Future for WriteChunk<'_> { type Output = Result<(), WriteError>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut(); @@ -411,7 +411,7 @@ struct WriteAllChunks<'a> { offset: usize, } -impl<'a> Future for WriteAllChunks<'a> { +impl Future for WriteAllChunks<'_> { type Output = Result<(), WriteError>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let this = self.get_mut();