From 84c5674c601dfc36ab417ff0ec01763c2dd30a5c Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 7 Jan 2024 02:33:37 +0900 Subject: [PATCH] ci: update clippy version to 1.75 (#6273) --- .clippy.toml | 1 - .github/workflows/ci.yml | 4 ++-- CONTRIBUTING.md | 2 +- tokio-stream/src/wrappers/lines.rs | 1 - tokio-stream/src/wrappers/split.rs | 1 - tokio-test/src/task.rs | 2 -- tokio-util/src/sync/cancellation_token/tree_node.rs | 2 ++ tokio-util/src/time/wheel/level.rs | 2 +- tokio-util/tests/compat.rs | 2 +- tokio-util/tests/mpsc.rs | 2 +- tokio-util/tests/spawn_pinned.rs | 4 ++-- tokio/src/io/bsd/poll_aio.rs | 2 +- tokio/src/lib.rs | 3 +-- tokio/src/runtime/scheduler/current_thread/mod.rs | 6 ------ tokio/src/runtime/task/state.rs | 3 --- tokio/src/runtime/time/wheel/level.rs | 2 +- tokio/src/signal/registry.rs | 2 -- tokio/tests/io_async_fd.rs | 2 +- tokio/tests/io_repeat.rs | 2 +- tokio/tests/io_sink.rs | 2 +- tokio/tests/macros_try_join.rs | 9 ++------- tokio/tests/net_named_pipe.rs | 6 +++--- tokio/tests/net_panic.rs | 4 ++-- tokio/tests/rt_time_start_paused.rs | 2 +- tokio/tests/task_id.rs | 1 - tokio/tests/task_join_set.rs | 6 +++--- tokio/tests/task_local.rs | 2 +- tokio/tests/task_panic.rs | 3 +-- tokio/tests/tcp_into_split.rs | 2 +- tokio/tests/time_panic.rs | 2 +- 30 files changed, 31 insertions(+), 53 deletions(-) delete mode 100644 .clippy.toml diff --git a/.clippy.toml b/.clippy.toml deleted file mode 100644 index 550d4759a..000000000 --- a/.clippy.toml +++ /dev/null @@ -1 +0,0 @@ -msrv = "1.63" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2242d3b8..2b79ec21c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ env: # Change to specific Rust release to pin rust_stable: stable rust_nightly: nightly-2023-10-21 - rust_clippy: 1.65.0 + rust_clippy: '1.75' # When updating this, also update: # - README.md # - tokio/README.md @@ -25,7 +25,7 @@ env: # - tokio-util/Cargo.toml # - tokio-test/Cargo.toml # - tokio-stream/Cargo.toml - rust_min: 1.63.0 + rust_min: '1.63' defaults: run: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 57a3bb366..a1fd3bf0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -149,7 +149,7 @@ When updating this, also update: --> ``` -cargo +1.65.0 clippy --all --tests --all-features +cargo +1.75 clippy --all --tests --all-features ``` When building documentation normally, the markers that list the features diff --git a/tokio-stream/src/wrappers/lines.rs b/tokio-stream/src/wrappers/lines.rs index ad3c25349..4850429a7 100644 --- a/tokio-stream/src/wrappers/lines.rs +++ b/tokio-stream/src/wrappers/lines.rs @@ -30,7 +30,6 @@ impl LinesStream { } /// Obtain a pinned reference to the inner `Lines`. - #[allow(clippy::wrong_self_convention)] // https://github.com/rust-lang/rust-clippy/issues/4546 pub fn as_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Lines> { self.project().inner } diff --git a/tokio-stream/src/wrappers/split.rs b/tokio-stream/src/wrappers/split.rs index 5a6bb2d40..ac46a8ba6 100644 --- a/tokio-stream/src/wrappers/split.rs +++ b/tokio-stream/src/wrappers/split.rs @@ -30,7 +30,6 @@ impl SplitStream { } /// Obtain a pinned reference to the inner `Split`. - #[allow(clippy::wrong_self_convention)] // https://github.com/rust-lang/rust-clippy/issues/4546 pub fn as_pin_mut(self: Pin<&mut Self>) -> Pin<&mut Split> { self.project().inner } diff --git a/tokio-test/src/task.rs b/tokio-test/src/task.rs index 67d558dde..a9cf50f52 100644 --- a/tokio-test/src/task.rs +++ b/tokio-test/src/task.rs @@ -25,8 +25,6 @@ //! assert!(task.poll().is_ready(), "Task was not ready!"); //! ``` -#![allow(clippy::mutex_atomic)] - use std::future::Future; use std::mem; use std::ops; diff --git a/tokio-util/src/sync/cancellation_token/tree_node.rs b/tokio-util/src/sync/cancellation_token/tree_node.rs index b7a98059e..0263f3111 100644 --- a/tokio-util/src/sync/cancellation_token/tree_node.rs +++ b/tokio-util/src/sync/cancellation_token/tree_node.rs @@ -178,6 +178,8 @@ where locked_node = node.inner.lock().unwrap(); locked_parent } + // https://github.com/tokio-rs/tokio/pull/6273#discussion_r1443752911 + #[allow(clippy::unnecessary_literal_unwrap)] Err(TryLockError::Poisoned(err)) => Err(err).unwrap(), }; diff --git a/tokio-util/src/time/wheel/level.rs b/tokio-util/src/time/wheel/level.rs index 4290acf9c..a69aee918 100644 --- a/tokio-util/src/time/wheel/level.rs +++ b/tokio-util/src/time/wheel/level.rs @@ -270,7 +270,7 @@ mod test { for level in 1..5 { for pos in level..64 { let a = pos * 64_usize.pow(level as u32); - assert_eq!(pos as usize, slot_for(a as u64, level)); + assert_eq!(pos, slot_for(a as u64, level)); } } } diff --git a/tokio-util/tests/compat.rs b/tokio-util/tests/compat.rs index 278ebfcfb..8a0eab340 100644 --- a/tokio-util/tests/compat.rs +++ b/tokio-util/tests/compat.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "compat"))] +#![cfg(feature = "compat")] #![cfg(not(target_os = "wasi"))] // WASI does not support all fs operations #![warn(rust_2018_idioms)] diff --git a/tokio-util/tests/mpsc.rs b/tokio-util/tests/mpsc.rs index 74b83c211..545a58031 100644 --- a/tokio-util/tests/mpsc.rs +++ b/tokio-util/tests/mpsc.rs @@ -29,7 +29,7 @@ async fn simple() { #[tokio::test] async fn simple_ref() { - let v = vec![1, 2, 3i32]; + let v = [1, 2, 3i32]; let (send, mut recv) = channel(3); let mut send = PollSender::new(send); diff --git a/tokio-util/tests/spawn_pinned.rs b/tokio-util/tests/spawn_pinned.rs index 9ea8cd278..9eeeecfb0 100644 --- a/tokio-util/tests/spawn_pinned.rs +++ b/tokio-util/tests/spawn_pinned.rs @@ -31,7 +31,7 @@ fn can_drop_future_and_still_get_output() { let pool = task::LocalPoolHandle::new(1); let (sender, receiver) = std::sync::mpsc::channel(); - let _ = pool.spawn_pinned(move || { + pool.spawn_pinned(move || { // Rc is !Send + !Sync let local_data = Rc::new("test"); @@ -209,7 +209,7 @@ async fn spawn_by_idx() { }, 0, ); - let _ = pool.spawn_pinned_by_idx( + pool.spawn_pinned_by_idx( || async move { barrier2.wait().await; std::thread::current().id() diff --git a/tokio/src/io/bsd/poll_aio.rs b/tokio/src/io/bsd/poll_aio.rs index 6ac9e2880..708ca7484 100644 --- a/tokio/src/io/bsd/poll_aio.rs +++ b/tokio/src/io/bsd/poll_aio.rs @@ -164,7 +164,7 @@ impl Aio { /// is scheduled to receive a wakeup when the underlying operation /// completes. Note that on multiple calls to `poll_ready`, only the `Waker` from the /// `Context` passed to the most recent call is scheduled to receive a wakeup. - pub fn poll_ready<'a>(&'a self, cx: &mut Context<'_>) -> Poll> { + pub fn poll_ready(&self, cx: &mut Context<'_>) -> Poll> { let ev = ready!(self.registration.poll_read_ready(cx))?; Poll::Ready(Ok(AioEvent(ev))) } diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 21d19bac9..3a9793968 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -2,8 +2,7 @@ clippy::cognitive_complexity, clippy::large_enum_variant, clippy::module_inception, - clippy::needless_doctest_main, - clippy::declare_interior_mutable_const + clippy::needless_doctest_main )] #![warn( missing_debug_implementations, diff --git a/tokio/src/runtime/scheduler/current_thread/mod.rs b/tokio/src/runtime/scheduler/current_thread/mod.rs index 3ae3d7acc..55a439701 100644 --- a/tokio/src/runtime/scheduler/current_thread/mod.rs +++ b/tokio/src/runtime/scheduler/current_thread/mod.rs @@ -351,9 +351,6 @@ impl Context { let mut driver = core.driver.take().expect("driver missing"); if let Some(f) = &handle.shared.config.before_park { - // Incorrect lint, the closures are actually different types so `f` - // cannot be passed as an argument to `enter`. - #[allow(clippy::redundant_closure)] let (c, ()) = self.enter(core, || f()); core = c; } @@ -374,9 +371,6 @@ impl Context { } if let Some(f) = &handle.shared.config.after_unpark { - // Incorrect lint, the closures are actually different types so `f` - // cannot be passed as an argument to `enter`. - #[allow(clippy::redundant_closure)] let (c, ()) = self.enter(core, || f()); core = c; } diff --git a/tokio/src/runtime/task/state.rs b/tokio/src/runtime/task/state.rs index 25c6b434a..24cb4338b 100644 --- a/tokio/src/runtime/task/state.rs +++ b/tokio/src/runtime/task/state.rs @@ -29,15 +29,12 @@ const LIFECYCLE_MASK: usize = 0b11; const NOTIFIED: usize = 0b100; /// The join handle is still around. -#[allow(clippy::unusual_byte_groupings)] // https://github.com/rust-lang/rust-clippy/issues/6556 const JOIN_INTEREST: usize = 0b1_000; /// A join handle waker has been set. -#[allow(clippy::unusual_byte_groupings)] // https://github.com/rust-lang/rust-clippy/issues/6556 const JOIN_WAKER: usize = 0b10_000; /// The task has been forcibly cancelled. -#[allow(clippy::unusual_byte_groupings)] // https://github.com/rust-lang/rust-clippy/issues/6556 const CANCELLED: usize = 0b100_000; /// All bits. diff --git a/tokio/src/runtime/time/wheel/level.rs b/tokio/src/runtime/time/wheel/level.rs index 7e48ff5c5..4c9ba18cd 100644 --- a/tokio/src/runtime/time/wheel/level.rs +++ b/tokio/src/runtime/time/wheel/level.rs @@ -267,7 +267,7 @@ mod test { for level in 1..5 { for pos in level..64 { let a = pos * 64_usize.pow(level as u32); - assert_eq!(pos as usize, slot_for(a as u64, level)); + assert_eq!(pos, slot_for(a as u64, level)); } } } diff --git a/tokio/src/signal/registry.rs b/tokio/src/signal/registry.rs index 022ad082b..74973293a 100644 --- a/tokio/src/signal/registry.rs +++ b/tokio/src/signal/registry.rs @@ -1,5 +1,3 @@ -#![allow(clippy::unit_arg)] - use crate::signal::os::{OsExtraData, OsStorage}; use crate::sync::watch; use crate::util::once_cell::OnceCell; diff --git a/tokio/tests/io_async_fd.rs b/tokio/tests/io_async_fd.rs index bacf8e843..1fb203a65 100644 --- a/tokio/tests/io_async_fd.rs +++ b/tokio/tests/io_async_fd.rs @@ -825,7 +825,7 @@ async fn await_error_readiness_invalid_address() { msg.msg_iovlen = 1; if unsafe { libc::sendmsg(socket_fd, &msg, 0) } == -1 { - Err(std::io::Error::last_os_error()).unwrap() + panic!("{:?}", std::io::Error::last_os_error()) } }); diff --git a/tokio/tests/io_repeat.rs b/tokio/tests/io_repeat.rs index 8094ffe7d..b3745877c 100644 --- a/tokio/tests/io_repeat.rs +++ b/tokio/tests/io_repeat.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full"))] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; diff --git a/tokio/tests/io_sink.rs b/tokio/tests/io_sink.rs index 9b4fb31f3..fb085c515 100644 --- a/tokio/tests/io_sink.rs +++ b/tokio/tests/io_sink.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full"))] +#![cfg(feature = "full")] use tokio::io::AsyncWriteExt; diff --git a/tokio/tests/macros_try_join.rs b/tokio/tests/macros_try_join.rs index c8ed00bcd..76958f167 100644 --- a/tokio/tests/macros_try_join.rs +++ b/tokio/tests/macros_try_join.rs @@ -45,8 +45,7 @@ async fn two_await() { let (tx1, rx1) = oneshot::channel::<&str>(); let (tx2, rx2) = oneshot::channel::(); - let mut join = - task::spawn(async { tokio::try_join!(async { rx1.await }, async { rx2.await }) }); + let mut join = task::spawn(async { tokio::try_join!(rx1, rx2) }); assert_pending!(join.poll()); @@ -67,11 +66,7 @@ async fn err_abort_early() { let (tx2, rx2) = oneshot::channel::(); let (_tx3, rx3) = oneshot::channel::(); - let mut join = task::spawn(async { - tokio::try_join!(async { rx1.await }, async { rx2.await }, async { - rx3.await - }) - }); + let mut join = task::spawn(async { tokio::try_join!(rx1, rx2, rx3) }); assert_pending!(join.poll()); diff --git a/tokio/tests/net_named_pipe.rs b/tokio/tests/net_named_pipe.rs index 02eda48e5..48b9da829 100644 --- a/tokio/tests/net_named_pipe.rs +++ b/tokio/tests/net_named_pipe.rs @@ -1,5 +1,5 @@ #![cfg(feature = "full")] -#![cfg(all(windows))] +#![cfg(windows)] use std::io; use std::time::Duration; @@ -92,7 +92,7 @@ async fn test_named_pipe_multi_client() -> io::Result<()> { // `io::ErrorKind::NotFound`. server = ServerOptions::new().create(PIPE_NAME)?; - let _ = tokio::spawn(async move { + tokio::spawn(async move { let mut buf = String::new(); inner.read_line(&mut buf).await?; inner.write_all(b"pong\n").await?; @@ -170,7 +170,7 @@ async fn test_named_pipe_multi_client_ready() -> io::Result<()> { // `io::ErrorKind::NotFound`. server = ServerOptions::new().create(PIPE_NAME)?; - let _ = tokio::spawn(async move { + tokio::spawn(async move { let server = inner_server; { diff --git a/tokio/tests/net_panic.rs b/tokio/tests/net_panic.rs index a7ce0afc0..81c9df55e 100644 --- a/tokio/tests/net_panic.rs +++ b/tokio/tests/net_panic.rs @@ -101,7 +101,7 @@ fn unix_listener_from_std_panic_caller() -> Result<(), Box> { let dir = tempfile::tempdir().unwrap(); let sock_path = dir.path().join("socket"); - let std_listener = std::os::unix::net::UnixListener::bind(&sock_path).unwrap(); + let std_listener = std::os::unix::net::UnixListener::bind(sock_path).unwrap(); let panic_location_file = test_panic(|| { let rt = runtime_without_io(); @@ -150,7 +150,7 @@ fn unix_datagram_from_std_panic_caller() -> Result<(), Box> { // Bind the socket to a filesystem path // /let socket_path = tmp.path().join("socket"); - let std_socket = StdUDS::bind(&sock_path).unwrap(); + let std_socket = StdUDS::bind(sock_path).unwrap(); std_socket.set_nonblocking(true).unwrap(); let panic_location_file = test_panic(move || { diff --git a/tokio/tests/rt_time_start_paused.rs b/tokio/tests/rt_time_start_paused.rs index 283f4748a..1765d625e 100644 --- a/tokio/tests/rt_time_start_paused.rs +++ b/tokio/tests/rt_time_start_paused.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "full"))] +#![cfg(feature = "full")] use tokio::time::{Duration, Instant}; diff --git a/tokio/tests/task_id.rs b/tokio/tests/task_id.rs index e10f24be9..95e48f490 100644 --- a/tokio/tests/task_id.rs +++ b/tokio/tests/task_id.rs @@ -1,5 +1,4 @@ #![warn(rust_2018_idioms)] -#![allow(clippy::declare_interior_mutable_const)] #![cfg(all(feature = "full", tokio_unstable))] #[cfg(not(target_os = "wasi"))] diff --git a/tokio/tests/task_join_set.rs b/tokio/tests/task_join_set.rs index d236aa1fc..bed9b7dad 100644 --- a/tokio/tests/task_join_set.rs +++ b/tokio/tests/task_join_set.rs @@ -23,7 +23,7 @@ async fn test_with_sleep() { set.detach_all(); assert_eq!(set.len(), 0); - assert!(matches!(set.join_next().await, None)); + assert!(set.join_next().await.is_none()); for i in 0..10 { set.spawn(async move { @@ -41,7 +41,7 @@ async fn test_with_sleep() { for was_seen in &seen { assert!(was_seen); } - assert!(matches!(set.join_next().await, None)); + assert!(set.join_next().await.is_none()); // Do it again. for i in 0..10 { @@ -59,7 +59,7 @@ async fn test_with_sleep() { for was_seen in &seen { assert!(was_seen); } - assert!(matches!(set.join_next().await, None)); + assert!(set.join_next().await.is_none()); } #[tokio::test] diff --git a/tokio/tests/task_local.rs b/tokio/tests/task_local.rs index a9ffaa15a..fbc885c35 100644 --- a/tokio/tests/task_local.rs +++ b/tokio/tests/task_local.rs @@ -1,5 +1,5 @@ #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads -#![allow(clippy::declare_interior_mutable_const)] + use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; diff --git a/tokio/tests/task_panic.rs b/tokio/tests/task_panic.rs index 47f3d6f0f..eb302d632 100644 --- a/tokio/tests/task_panic.rs +++ b/tokio/tests/task_panic.rs @@ -1,5 +1,4 @@ #![warn(rust_2018_idioms)] -#![allow(clippy::declare_interior_mutable_const)] #![cfg(all(feature = "full", not(target_os = "wasi")))] use futures::future; @@ -34,7 +33,7 @@ fn local_set_spawn_local_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { let _local = task::LocalSet::new(); - let _ = task::spawn_local(async {}); + task::spawn_local(async {}); }); // The panic location should be in this file diff --git a/tokio/tests/tcp_into_split.rs b/tokio/tests/tcp_into_split.rs index 2a030691f..df8efadb5 100644 --- a/tokio/tests/tcp_into_split.rs +++ b/tokio/tests/tcp_into_split.rs @@ -38,7 +38,7 @@ async fn split() -> Result<()> { Ok(()) }, async { - let mut read_buf = vec![0u8; 32]; + let mut read_buf = [0u8; 32]; let peek_len1 = read_half.peek(&mut read_buf[..]).await?; let peek_len2 = read_half.peek(&mut read_buf[..]).await?; assert_eq!(peek_len1, peek_len2); diff --git a/tokio/tests/time_panic.rs b/tokio/tests/time_panic.rs index 2b8e09573..0532812d3 100644 --- a/tokio/tests/time_panic.rs +++ b/tokio/tests/time_panic.rs @@ -80,7 +80,7 @@ fn timeout_panic_caller() -> Result<(), Box> { // Runtime without `enable_time` so it has no current timer set. let rt = Builder::new_current_thread().build().unwrap(); rt.block_on(async { - let _ = timeout(Duration::from_millis(5), future::pending::<()>()); + let _timeout = timeout(Duration::from_millis(5), future::pending::<()>()); }); });