macros: suppress clippy::default_numeric_fallback lint in generated code (#3831)

This commit is contained in:
Taiki Endo 2021-06-02 18:16:23 +09:00 committed by GitHub
parent d4c89758fc
commit 9d8b37d51a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 27 additions and 22 deletions

1
.clippy.toml Normal file
View File

@ -0,0 +1 @@
msrv = "1.45"

View File

@ -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

View File

@ -1,3 +1,5 @@
#![allow(clippy::diverging_sub_expression)]
use std::rc::Rc;
#[allow(dead_code)]

View File

@ -6,9 +6,9 @@ use tokio_util::sync::PollSemaphore;
type SemRet = Option<OwnedSemaphorePermit>;
fn semaphore_poll<'a>(
sem: &'a mut PollSemaphore,
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + 'a> {
fn semaphore_poll(
sem: &mut PollSemaphore,
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + '_> {
let fut = futures::future::poll_fn(move |cx| sem.poll_acquire(cx));
tokio_test::task::spawn(fut)
}

View File

@ -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;
}
)*

View File

@ -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

View File

@ -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<Self::Target>;
/// Convert the raw pointer to a handle

View File

@ -54,11 +54,7 @@ unsafe fn inc_ref_count<T: Wake>(data: *const ()) {
let arc = ManuallyDrop::new(Arc::<T>::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<T: Wake>(data: *const ()) -> RawWaker {

View File

@ -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;

View File

@ -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 => (),
}
}

View File

@ -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

View File

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