diff --git a/.clippy.toml b/.clippy.toml new file mode 100644 index 00000000000..1cf14c6d01e --- /dev/null +++ b/.clippy.toml @@ -0,0 +1 @@ +msrv = "1.45" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 217012dabad..bd0650cba3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -265,7 +265,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install Rust - run: rustup update ${{ env.minrust }} && rustup default ${{ env.minrust }} + run: rustup update 1.52.1 && rustup default 1.52.1 - name: Install clippy run: rustup component add clippy diff --git a/tokio-stream/tests/async_send_sync.rs b/tokio-stream/tests/async_send_sync.rs index c06bebd22e4..f1c8b4efe25 100644 --- a/tokio-stream/tests/async_send_sync.rs +++ b/tokio-stream/tests/async_send_sync.rs @@ -1,3 +1,5 @@ +#![allow(clippy::diverging_sub_expression)] + use std::rc::Rc; #[allow(dead_code)] diff --git a/tokio-util/tests/poll_semaphore.rs b/tokio-util/tests/poll_semaphore.rs index 0fdb3a446f7..50f36dd803b 100644 --- a/tokio-util/tests/poll_semaphore.rs +++ b/tokio-util/tests/poll_semaphore.rs @@ -6,9 +6,9 @@ use tokio_util::sync::PollSemaphore; type SemRet = Option; -fn semaphore_poll<'a>( - sem: &'a mut PollSemaphore, -) -> tokio_test::task::Spawn + 'a> { +fn semaphore_poll( + sem: &mut PollSemaphore, +) -> tokio_test::task::Spawn + '_> { let fut = futures::future::poll_fn(move |cx| sem.poll_acquire(cx)); tokio_test::task::spawn(fut) } diff --git a/tokio/src/macros/select.rs b/tokio/src/macros/select.rs index f98ebff4ff0..371a3debb55 100644 --- a/tokio/src/macros/select.rs +++ b/tokio/src/macros/select.rs @@ -398,7 +398,7 @@ macro_rules! select { // set the appropriate bit in `disabled`. $( if !$c { - let mask = 1 << $crate::count!( $($skip)* ); + let mask: util::Mask = 1 << $crate::count!( $($skip)* ); disabled |= mask; } )* diff --git a/tokio/src/runtime/task/state.rs b/tokio/src/runtime/task/state.rs index 1e09f423079..87bb02517bb 100644 --- a/tokio/src/runtime/task/state.rs +++ b/tokio/src/runtime/task/state.rs @@ -29,12 +29,15 @@ 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/util/linked_list.rs b/tokio/src/util/linked_list.rs index 480ea093b55..a74f56215d9 100644 --- a/tokio/src/util/linked_list.rs +++ b/tokio/src/util/linked_list.rs @@ -50,6 +50,7 @@ pub(crate) unsafe trait Link { type Target; /// Convert the handle to a raw pointer without consuming the handle + #[allow(clippy::wrong_self_convention)] fn as_raw(handle: &Self::Handle) -> NonNull; /// Convert the raw pointer to a handle diff --git a/tokio/src/util/wake.rs b/tokio/src/util/wake.rs index 001577d7443..57739371d20 100644 --- a/tokio/src/util/wake.rs +++ b/tokio/src/util/wake.rs @@ -54,11 +54,7 @@ unsafe fn inc_ref_count(data: *const ()) { let arc = ManuallyDrop::new(Arc::::from_raw(data as *const T)); // Now increase refcount, but don't drop new refcount either - let arc_clone: ManuallyDrop<_> = arc.clone(); - - // Drop explicitly to avoid clippy warnings - drop(arc); - drop(arc_clone); + let _arc_clone: ManuallyDrop<_> = arc.clone(); } unsafe fn clone_arc_raw(data: *const ()) -> RawWaker { diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index 211c572cf2b..01e608186f4 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -1,6 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] -#![allow(clippy::type_complexity)] +#![allow(clippy::type_complexity, clippy::diverging_sub_expression)] use std::cell::Cell; use std::future::Future; diff --git a/tokio/tests/macros_select.rs b/tokio/tests/macros_select.rs index 07c2b81f5fa..a089602cb59 100644 --- a/tokio/tests/macros_select.rs +++ b/tokio/tests/macros_select.rs @@ -537,3 +537,13 @@ async fn biased_eventually_ready() { assert_eq!(count, 3); } + +// https://github.com/tokio-rs/tokio/issues/3830 +// https://github.com/rust-lang/rust-clippy/issues/7304 +#[warn(clippy::default_numeric_fallback)] +pub async fn default_numeric_fallback() { + tokio::select! { + _ = async {} => (), + else => (), + } +} diff --git a/tokio/tests/macros_test.rs b/tokio/tests/macros_test.rs index f5bc5a0330f..7212c7ba183 100644 --- a/tokio/tests/macros_test.rs +++ b/tokio/tests/macros_test.rs @@ -2,20 +2,12 @@ use tokio::test; #[test] async fn test_macro_can_be_used_via_use() { - tokio::spawn(async { - assert_eq!(1 + 1, 2); - }) - .await - .unwrap(); + tokio::spawn(async {}).await.unwrap(); } #[tokio::test] async fn test_macro_is_resilient_to_shadowing() { - tokio::spawn(async { - assert_eq!(1 + 1, 2); - }) - .await - .unwrap(); + tokio::spawn(async {}).await.unwrap(); } // https://github.com/tokio-rs/tokio/issues/3403 diff --git a/tokio/tests/task_blocking.rs b/tokio/tests/task_blocking.rs index 82bef8a1d58..ee7e78ad482 100644 --- a/tokio/tests/task_blocking.rs +++ b/tokio/tests/task_blocking.rs @@ -132,7 +132,7 @@ fn useful_panic_message_when_dropping_rt_in_rt() { let err: &'static str = err.downcast_ref::<&'static str>().unwrap(); assert!( - err.find("Cannot drop a runtime").is_some(), + err.contains("Cannot drop a runtime"), "Wrong panic message: {:?}", err );