mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
macros: suppress clippy::default_numeric_fallback lint in generated code (#3831)
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
msrv = "1.45"
|
||||||
@@ -265,7 +265,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install Rust
|
- 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
|
- name: Install clippy
|
||||||
run: rustup component add clippy
|
run: rustup component add clippy
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(clippy::diverging_sub_expression)]
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ use tokio_util::sync::PollSemaphore;
|
|||||||
|
|
||||||
type SemRet = Option<OwnedSemaphorePermit>;
|
type SemRet = Option<OwnedSemaphorePermit>;
|
||||||
|
|
||||||
fn semaphore_poll<'a>(
|
fn semaphore_poll(
|
||||||
sem: &'a mut PollSemaphore,
|
sem: &mut PollSemaphore,
|
||||||
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + 'a> {
|
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + '_> {
|
||||||
let fut = futures::future::poll_fn(move |cx| sem.poll_acquire(cx));
|
let fut = futures::future::poll_fn(move |cx| sem.poll_acquire(cx));
|
||||||
tokio_test::task::spawn(fut)
|
tokio_test::task::spawn(fut)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ macro_rules! select {
|
|||||||
// set the appropriate bit in `disabled`.
|
// set the appropriate bit in `disabled`.
|
||||||
$(
|
$(
|
||||||
if !$c {
|
if !$c {
|
||||||
let mask = 1 << $crate::count!( $($skip)* );
|
let mask: util::Mask = 1 << $crate::count!( $($skip)* );
|
||||||
disabled |= mask;
|
disabled |= mask;
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
|||||||
@@ -29,12 +29,15 @@ const LIFECYCLE_MASK: usize = 0b11;
|
|||||||
const NOTIFIED: usize = 0b100;
|
const NOTIFIED: usize = 0b100;
|
||||||
|
|
||||||
/// The join handle is still around
|
/// 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;
|
const JOIN_INTEREST: usize = 0b1_000;
|
||||||
|
|
||||||
/// A join handle waker has been set
|
/// 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;
|
const JOIN_WAKER: usize = 0b10_000;
|
||||||
|
|
||||||
/// The task has been forcibly cancelled.
|
/// 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;
|
const CANCELLED: usize = 0b100_000;
|
||||||
|
|
||||||
/// All bits
|
/// All bits
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ pub(crate) unsafe trait Link {
|
|||||||
type Target;
|
type Target;
|
||||||
|
|
||||||
/// Convert the handle to a raw pointer without consuming the handle
|
/// 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>;
|
fn as_raw(handle: &Self::Handle) -> NonNull<Self::Target>;
|
||||||
|
|
||||||
/// Convert the raw pointer to a handle
|
/// 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));
|
let arc = ManuallyDrop::new(Arc::<T>::from_raw(data as *const T));
|
||||||
|
|
||||||
// Now increase refcount, but don't drop new refcount either
|
// Now increase refcount, but don't drop new refcount either
|
||||||
let arc_clone: ManuallyDrop<_> = arc.clone();
|
let _arc_clone: ManuallyDrop<_> = arc.clone();
|
||||||
|
|
||||||
// Drop explicitly to avoid clippy warnings
|
|
||||||
drop(arc);
|
|
||||||
drop(arc_clone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_arc_raw<T: Wake>(data: *const ()) -> RawWaker {
|
unsafe fn clone_arc_raw<T: Wake>(data: *const ()) -> RawWaker {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
#![cfg(feature = "full")]
|
#![cfg(feature = "full")]
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity, clippy::diverging_sub_expression)]
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|||||||
@@ -537,3 +537,13 @@ async fn biased_eventually_ready() {
|
|||||||
|
|
||||||
assert_eq!(count, 3);
|
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]
|
#[test]
|
||||||
async fn test_macro_can_be_used_via_use() {
|
async fn test_macro_can_be_used_via_use() {
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {}).await.unwrap();
|
||||||
assert_eq!(1 + 1, 2);
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_macro_is_resilient_to_shadowing() {
|
async fn test_macro_is_resilient_to_shadowing() {
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {}).await.unwrap();
|
||||||
assert_eq!(1 + 1, 2);
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/tokio-rs/tokio/issues/3403
|
// 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();
|
let err: &'static str = err.downcast_ref::<&'static str>().unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
err.find("Cannot drop a runtime").is_some(),
|
err.contains("Cannot drop a runtime"),
|
||||||
"Wrong panic message: {:?}",
|
"Wrong panic message: {:?}",
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user