Skip to content

Commit 9d8b37d

Browse files
authored
macros: suppress clippy::default_numeric_fallback lint in generated code (#3831)
1 parent d4c8975 commit 9d8b37d

File tree

12 files changed

+27
-22
lines changed

12 files changed

+27
-22
lines changed

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.45"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ jobs:
265265
steps:
266266
- uses: actions/checkout@v2
267267
- name: Install Rust
268-
run: rustup update ${{ env.minrust }} && rustup default ${{ env.minrust }}
268+
run: rustup update 1.52.1 && rustup default 1.52.1
269269
- name: Install clippy
270270
run: rustup component add clippy
271271

tokio-stream/tests/async_send_sync.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::diverging_sub_expression)]
2+
13
use std::rc::Rc;
24

35
#[allow(dead_code)]

tokio-util/tests/poll_semaphore.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use tokio_util::sync::PollSemaphore;
66

77
type SemRet = Option<OwnedSemaphorePermit>;
88

9-
fn semaphore_poll<'a>(
10-
sem: &'a mut PollSemaphore,
11-
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + 'a> {
9+
fn semaphore_poll(
10+
sem: &mut PollSemaphore,
11+
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + '_> {
1212
let fut = futures::future::poll_fn(move |cx| sem.poll_acquire(cx));
1313
tokio_test::task::spawn(fut)
1414
}

tokio/src/macros/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ macro_rules! select {
398398
// set the appropriate bit in `disabled`.
399399
$(
400400
if !$c {
401-
let mask = 1 << $crate::count!( $($skip)* );
401+
let mask: util::Mask = 1 << $crate::count!( $($skip)* );
402402
disabled |= mask;
403403
}
404404
)*

tokio/src/runtime/task/state.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ const LIFECYCLE_MASK: usize = 0b11;
2929
const NOTIFIED: usize = 0b100;
3030

3131
/// The join handle is still around
32+
#[allow(clippy::unusual_byte_groupings)] // https://github.com/rust-lang/rust-clippy/issues/6556
3233
const JOIN_INTEREST: usize = 0b1_000;
3334

3435
/// A join handle waker has been set
36+
#[allow(clippy::unusual_byte_groupings)] // https://github.com/rust-lang/rust-clippy/issues/6556
3537
const JOIN_WAKER: usize = 0b10_000;
3638

3739
/// The task has been forcibly cancelled.
40+
#[allow(clippy::unusual_byte_groupings)] // https://github.com/rust-lang/rust-clippy/issues/6556
3841
const CANCELLED: usize = 0b100_000;
3942

4043
/// All bits

tokio/src/util/linked_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub(crate) unsafe trait Link {
5050
type Target;
5151

5252
/// Convert the handle to a raw pointer without consuming the handle
53+
#[allow(clippy::wrong_self_convention)]
5354
fn as_raw(handle: &Self::Handle) -> NonNull<Self::Target>;
5455

5556
/// Convert the raw pointer to a handle

tokio/src/util/wake.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ unsafe fn inc_ref_count<T: Wake>(data: *const ()) {
5454
let arc = ManuallyDrop::new(Arc::<T>::from_raw(data as *const T));
5555

5656
// Now increase refcount, but don't drop new refcount either
57-
let arc_clone: ManuallyDrop<_> = arc.clone();
58-
59-
// Drop explicitly to avoid clippy warnings
60-
drop(arc);
61-
drop(arc_clone);
57+
let _arc_clone: ManuallyDrop<_> = arc.clone();
6258
}
6359

6460
unsafe fn clone_arc_raw<T: Wake>(data: *const ()) -> RawWaker {

tokio/tests/async_send_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
3-
#![allow(clippy::type_complexity)]
3+
#![allow(clippy::type_complexity, clippy::diverging_sub_expression)]
44

55
use std::cell::Cell;
66
use std::future::Future;

tokio/tests/macros_select.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,13 @@ async fn biased_eventually_ready() {
537537

538538
assert_eq!(count, 3);
539539
}
540+
541+
// https://github.com/tokio-rs/tokio/issues/3830
542+
// https://github.com/rust-lang/rust-clippy/issues/7304
543+
#[warn(clippy::default_numeric_fallback)]
544+
pub async fn default_numeric_fallback() {
545+
tokio::select! {
546+
_ = async {} => (),
547+
else => (),
548+
}
549+
}

0 commit comments

Comments
 (0)