Skip to content

Commit

Permalink
ci: update clippy version to 1.75 (#6273)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored Jan 6, 2024
1 parent 3275cfb commit 84c5674
Show file tree
Hide file tree
Showing 30 changed files with 31 additions and 53 deletions.
1 change: 0 additions & 1 deletion .clippy.toml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tokio-stream/src/wrappers/lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl<R> LinesStream<R> {
}

/// Obtain a pinned reference to the inner `Lines<R>`.
#[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<R>> {
self.project().inner
}
Expand Down
1 change: 0 additions & 1 deletion tokio-stream/src/wrappers/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl<R> SplitStream<R> {
}

/// Obtain a pinned reference to the inner `Split<R>`.
#[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<R>> {
self.project().inner
}
Expand Down
2 changes: 0 additions & 2 deletions tokio-test/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tokio-util/src/sync/cancellation_token/tree_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};

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 @@ -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));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/compat.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tokio-util/tests/spawn_pinned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/bsd/poll_aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<E: AioSource> Aio<E> {
/// 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<io::Result<AioEvent>> {
pub fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<AioEvent>> {
let ev = ready!(self.registration.poll_read_ready(cx))?;
Poll::Ready(Ok(AioEvent(ev)))
}
Expand Down
3 changes: 1 addition & 2 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions tokio/src/runtime/scheduler/current_thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions tokio/src/runtime/task/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/time/wheel/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions tokio/src/signal/registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::unit_arg)]

use crate::signal::os::{OsExtraData, OsStorage};
use crate::sync::watch;
use crate::util::once_cell::OnceCell;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
});

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_repeat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full"))]
#![cfg(feature = "full")]

use tokio::io::AsyncReadExt;

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_sink.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full"))]
#![cfg(feature = "full")]

use tokio::io::AsyncWriteExt;

Expand Down
9 changes: 2 additions & 7 deletions tokio/tests/macros_try_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ async fn two_await() {
let (tx1, rx1) = oneshot::channel::<&str>();
let (tx2, rx2) = oneshot::channel::<u32>();

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());

Expand All @@ -67,11 +66,7 @@ async fn err_abort_early() {
let (tx2, rx2) = oneshot::channel::<u32>();
let (_tx3, rx3) = oneshot::channel::<u32>();

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());

Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/net_named_pipe.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg(feature = "full")]
#![cfg(all(windows))]
#![cfg(windows)]

use std::io;
use std::time::Duration;
Expand Down Expand Up @@ -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?;
Expand Down Expand Up @@ -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;

{
Expand Down
4 changes: 2 additions & 2 deletions tokio/tests/net_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn unix_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {

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();
Expand Down Expand Up @@ -150,7 +150,7 @@ fn unix_datagram_from_std_panic_caller() -> Result<(), Box<dyn Error>> {

// 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 || {
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/rt_time_start_paused.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(all(feature = "full"))]
#![cfg(feature = "full")]

use tokio::time::{Duration, Instant};

Expand Down
1 change: 0 additions & 1 deletion tokio/tests/task_id.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/task_join_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/task_local.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
3 changes: 1 addition & 2 deletions tokio/tests/task_panic.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -34,7 +33,7 @@ fn local_set_spawn_local_panic_caller() -> Result<(), Box<dyn Error>> {
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
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/tcp_into_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/time_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn timeout_panic_caller() -> Result<(), Box<dyn Error>> {
// 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::<()>());
});
});

Expand Down

0 comments on commit 84c5674

Please sign in to comment.