mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
macros: suppress clippy::default_numeric_fallback lint in generated code (#3831)
This commit is contained in:
parent
d4c89758fc
commit
9d8b37d51a
1
.clippy.toml
Normal file
1
.clippy.toml
Normal file
@ -0,0 +1 @@
|
||||
msrv = "1.45"
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -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
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(clippy::diverging_sub_expression)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
)*
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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 => (),
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user