Skip to content

Commit

Permalink
allow clippy::needless_lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
rex4539 committed Feb 5, 2025
1 parent 3277912 commit e80f3cd
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
rust_nightly: nightly-2025-01-25
# Pin a specific miri version
rust_miri_nightly: nightly-2025-01-25
rust_clippy: 'nightly-2025-01-25'
rust_clippy: '1.84.1'
# When updating this, also update:
# - README.md
# - tokio/README.md
Expand Down
1 change: 1 addition & 0 deletions tokio-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::needless_lifetimes)]
#![allow(clippy::needless_doctest_main)]
#![warn(
missing_debug_implementations,
Expand Down
1 change: 0 additions & 1 deletion tokio-util/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl Listener for tokio::net::TcpListener {
Self::poll_accept(self, cx)
}

// Fixed: Removed the redundant conversion
fn local_addr(&self) -> Result<Self::Addr> {
self.local_addr()
}
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/time/wheel/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<T: Stack> Level<T> {
pub(crate) fn next_expiration(&self, now: u64) -> Option<Expiration> {
// Use the `occupied` bit field to get the index of the next slot that
// needs to be processed.
let slot = self.next_occupied_slot(now)?; // Replaced match with `?`
let slot = self.next_occupied_slot(now)?;

// From the slot index, calculate the `Instant` at which it needs to be
// processed. This value *must* be in the future with respect to `now`.
Expand Down
10 changes: 5 additions & 5 deletions tokio-util/src/time/wheel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ where
///
/// # Arguments
///
/// `when`: is the instant at which the entry should be fired. It is
/// represented as the number of milliseconds since the creation
/// of the timing wheel.
/// `when`: is the instant at which the entry should be fired. It is
/// represented as the number of milliseconds since the creation
/// of the timing wheel.
///
/// `item`: The item to insert into the wheel.
/// `item`: The item to insert into the wheel.
///
/// `store`: The slab or `()` when using heap storage.
/// `store`: The slab or `()` when using heap storage.
///
/// # Return
///
Expand Down
1 change: 1 addition & 0 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(
clippy::needless_lifetimes,
clippy::cognitive_complexity,
clippy::large_enum_variant,
clippy::module_inception,
Expand Down
16 changes: 8 additions & 8 deletions tokio/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
//!
//! # Organization
//!
//! [`TcpListener`] and [`TcpStream`] provide functionality for communication over TCP
//! [`UdpSocket`] provides functionality for communication over UDP
//! [`UnixListener`] and [`UnixStream`] provide functionality for communication over a
//! Unix Domain Stream Socket **(available on Unix only)**
//! [`UnixDatagram`] provides functionality for communication
//! over Unix Domain Datagram Socket **(available on Unix only)**
//! [`tokio::net::unix::pipe`] for FIFO pipes **(available on Unix only)**
//! [`tokio::net::windows::named_pipe`] for Named Pipes **(available on Windows only)**
//! [`TcpListener`] and [`TcpStream`] provide functionality for communication over TCP
//! [`UdpSocket`] provides functionality for communication over UDP
//! [`UnixListener`] and [`UnixStream`] provide functionality for communication over a
//! Unix Domain Stream Socket **(available on Unix only)**
//! [`UnixDatagram`] provides functionality for communication
//! over Unix Domain Datagram Socket **(available on Unix only)**
//! [`tokio::net::unix::pipe`] for FIFO pipes **(available on Unix only)**
//! [`tokio::net::windows::named_pipe`] for Named Pipes **(available on Windows only)**
//!
//! For IO resources not available in `tokio::net`, you can use [`AsyncFd`].
//!
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ impl Semaphore {
}
}

impl SemaphorePermit<'_> {
impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
Expand Down
30 changes: 15 additions & 15 deletions tokio/src/task/join_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ impl<T: 'static> JoinSet<T> {
///
/// This function returns:
///
/// `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// `Poll::Ready(Some(Ok(value)))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is the return value of one of the tasks that completed.
/// `Poll::Ready(Some(Err(err)))` if one of the tasks in this `JoinSet` has panicked or been
/// aborted. The `err` is the `JoinError` from the panicked/aborted task.
/// `Poll::Ready(None)` if the `JoinSet` is empty.
/// `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// `Poll::Ready(Some(Ok(value)))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is the return value of one of the tasks that completed.
/// `Poll::Ready(Some(Err(err)))` if one of the tasks in this `JoinSet` has panicked or been
/// aborted. The `err` is the `JoinError` from the panicked/aborted task.
/// `Poll::Ready(None)` if the `JoinSet` is empty.
///
/// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
Expand Down Expand Up @@ -525,14 +525,14 @@ impl<T: 'static> JoinSet<T> {
///
/// This function returns:
///
/// `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// `Poll::Ready(Some(Ok((id, value))))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is the return value of one of the tasks that completed, and
/// `id` is the [task ID] of that task.
/// `Poll::Ready(Some(Err(err)))` if one of the tasks in this `JoinSet` has panicked or been
/// aborted. The `err` is the `JoinError` from the panicked/aborted task.
/// `Poll::Ready(None)` if the `JoinSet` is empty.
/// `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// `Poll::Ready(Some(Ok((id, value))))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is the return value of one of the tasks that completed, and
/// `id` is the [task ID] of that task.
/// `Poll::Ready(Some(Err(err)))` if one of the tasks in this `JoinSet` has panicked or been
/// aborted. The `err` is the `JoinError` from the panicked/aborted task.
/// `Poll::Ready(None)` if the `JoinSet` is empty.
///
/// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/io_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl AsyncRead for R {
_cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
buf.put_slice(&[b'z']);
buf.put_slice(&[b'z'][..]);
Poll::Ready(Ok(()))
}
}
Expand Down Expand Up @@ -68,10 +68,10 @@ fn method_delegation() {
assert_eq!(1, rw.read(&mut buf).await.unwrap());
assert_eq!(b'z', buf[0]);

assert_eq!(1, rw.write(&[b'x']).await.unwrap());
assert_eq!(1, rw.write(&[b'x'][..]).await.unwrap());
assert_eq!(
2,
rw.write_vectored(&[io::IoSlice::new(&[b'x'])])
rw.write_vectored(&[io::IoSlice::new(&[b'x'][..])]).await.unwrap();
.await
.unwrap()
);
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn method_delegation() {
assert_eq!(1, w.write(&[b'x']).await.unwrap());
assert_eq!(
2,
w.write_vectored(&[io::IoSlice::new(&[b'x'])])
w.write_vectored(&[io::IoSlice::new(&[b"x"])])
.await
.unwrap()
);
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/support/io_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a, 'b> IoBufs<'a, 'b> {
}
}

impl<'a, 'b> Deref for IoBufs<'a, 'b> {
impl<'a> Deref for IoBufs<'a, '_> {
type Target = [IoSlice<'a>];
fn deref(&self) -> &[IoSlice<'a>] {
self.0
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/tcp_accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct TrackPolls<'a> {
listener: &'a mut TcpListener,
}

impl<'a> Stream for TrackPolls<'a> {
impl Stream for TrackPolls<'_> {
type Item = io::Result<(TcpStream, SocketAddr)>;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand Down

0 comments on commit e80f3cd

Please sign in to comment.