From 57f9245be407c46c1f908b3cef8677b0c722400e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 19 May 2026 19:20:53 +0100 Subject: [PATCH] address warnings --- Cargo.toml | 3 +++ src/native/atomic_waker.rs | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c3226c..6425508 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,6 @@ wasm-bindgen = [ "gloo-timers", "send_wrapper" ] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(assert_timer_heap_consistent)'] } diff --git a/src/native/atomic_waker.rs b/src/native/atomic_waker.rs index bc0432d..6183811 100644 --- a/src/native/atomic_waker.rs +++ b/src/native/atomic_waker.rs @@ -41,10 +41,6 @@ const WAKING: usize = 0b10; impl AtomicWaker { /// Create an `AtomicWaker`. pub fn new() -> AtomicWaker { - // Make sure that task is Sync - trait AssertSync: Sync {} - impl AssertSync for Waker {} - AtomicWaker { state: AtomicUsize::new(WAITING), waker: UnsafeCell::new(None), @@ -104,8 +100,11 @@ impl AtomicWaker { /// } /// ``` pub fn register(&self, waker: &Waker) { - match self.state.compare_and_swap(WAITING, REGISTERING, Acquire) { - WAITING => { + match self + .state + .compare_exchange(WAITING, REGISTERING, Acquire, Acquire) + { + Ok(_) => { unsafe { // Locked acquired, update the waker cell *self.waker.get() = Some(waker.clone()); @@ -144,13 +143,13 @@ impl AtomicWaker { } } } - WAKING => { + Err(WAKING) => { // Currently in the process of waking the task, i.e., // `wake` is currently being called on the old task handle. // So, we call wake on the new waker waker.wake_by_ref(); } - state => { + Err(state) => { // In this case, a concurrent thread is holding the // "registering" lock. This probably indicates a bug in the // caller's code as racing to call `register` doesn't make much