From eb54e95aca849d451b87bb7c13efce1afad5eabd Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 19 May 2024 10:43:48 -0700 Subject: [PATCH] m: Fix new nightly Clippy warnings - Suppress warning from the cfg(loom) directive by having it emit "rustc-check-cfg" in build.rs - Remove usage of legacy "std::usize" module. - Ignore "clippy::multiple_bound_locations". We use multiple bounds as a workaround for an issue in pin-project-lite where only one bound can be assigned per location. The phrasing of pin-project-lite's README implies that this issue is WONTFIX. To quote: > This library does not tackle as expansive of a range of use cases as > pin-project does. If your use case is not already covered, please use > pin-project. Signed-off-by: John Nunley --- build.rs | 7 +++++++ src/lib.rs | 5 +++-- src/no_std.rs | 2 +- src/std.rs | 2 +- tests/loom.rs | 1 - tests/notify.rs | 1 - 6 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 build.rs diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..c689ca8 --- /dev/null +++ b/build.rs @@ -0,0 +1,7 @@ +//! Emits the necessary "checked" compile time flag warning for "loom". +//! +//! Without this, the compiler complains about the unspecified "loom" flag. + +fn main() { + println!("cargo:rustc-check-cfg=cfg(loom)"); +} diff --git a/src/lib.rs b/src/lib.rs index 08d6037..c446749 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -68,6 +68,7 @@ //! [`portable-atomic`]: https://crates.io/crates/portable-atomic #![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::multiple_bound_locations)] // This is a WONTFIX issue with pin-project-lite #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] #![doc( html_favicon_url = "https://github.com/raw/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" @@ -131,7 +132,7 @@ struct Inner { impl Inner { fn new() -> Self { Self { - notified: AtomicUsize::new(core::usize::MAX), + notified: AtomicUsize::new(usize::MAX), list: sys::List::new(), } } @@ -438,7 +439,7 @@ impl Event { if let Some(inner) = self.try_inner() { let limit = if notify.is_additional(Internal::new()) { - core::usize::MAX + usize::MAX } else { notify.count(Internal::new()) }; diff --git a/src/no_std.rs b/src/no_std.rs index a2e6dc0..527fa9c 100644 --- a/src/no_std.rs +++ b/src/no_std.rs @@ -307,7 +307,7 @@ impl Drop for ListGuard<'_, T> { let notified = if list.notified < list.len { list.notified } else { - core::usize::MAX + usize::MAX }; self.inner.notified.store(notified, Ordering::Release); diff --git a/src/std.rs b/src/std.rs index 3e7f76a..0d39833 100644 --- a/src/std.rs +++ b/src/std.rs @@ -306,7 +306,7 @@ impl Drop for ListLock<'_, '_, T> { let notified = if list.notified < list.len { list.notified } else { - core::usize::MAX + usize::MAX }; self.inner.notified.store(notified, Ordering::Release); diff --git a/tests/loom.rs b/tests/loom.rs index 6ef1d05..1cd92e2 100644 --- a/tests/loom.rs +++ b/tests/loom.rs @@ -3,7 +3,6 @@ use std::future::Future; use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::task::Context; -use std::usize; use event_listener::{Event, EventListener}; use waker_fn::waker_fn; diff --git a/tests/notify.rs b/tests/notify.rs index 490a492..c37dc9a 100644 --- a/tests/notify.rs +++ b/tests/notify.rs @@ -2,7 +2,6 @@ use std::future::Future; use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::task::Context; -use std::usize; use event_listener::{Event, EventListener}; use waker_fn::waker_fn;