From fac19eb88dc24c1be10775d766d47de6c9759aed Mon Sep 17 00:00:00 2001 From: agent-p1p <292420120+agent-p1p@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:55:38 +0000 Subject: [PATCH] sdk: avoid deprecated `AtomicUsize::fetch_update` Rust 1.99 deprecates `fetch_update` in favor of `try_update`, so the "Check stable" CI job, which builds with `-D warnings`, fails on `PendingReqCounter::decrement`. `try_update` is above the 1.85 MSRV, so write out the compare-and-swap loop that `fetch_update` performs instead. The decrement still saturates at zero. Co-Authored-By: Claude Opus 5.5 --- nostr-sdk/src/relay/inner.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/nostr-sdk/src/relay/inner.rs b/nostr-sdk/src/relay/inner.rs index d12517550..a00e4f769 100644 --- a/nostr-sdk/src/relay/inner.rs +++ b/nostr-sdk/src/relay/inner.rs @@ -87,11 +87,19 @@ impl PendingReqCounter { #[inline] fn decrement(&self) { - let _ = self - .0 - .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |count| { - count.checked_sub(1) - }); + // Saturating decrement. Newer Rust deprecates `fetch_update` in favor of + // `try_update`, which is above the MSRV, so spell out its CAS loop. + let mut count: usize = self.0.load(Ordering::SeqCst); + + while let Some(next) = count.checked_sub(1) { + match self + .0 + .compare_exchange_weak(count, next, Ordering::SeqCst, Ordering::SeqCst) + { + Ok(_) => return, + Err(actual) => count = actual, + } + } } #[inline]