From e19b560b3014c9ec58dede1947070ca82cf95c58 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 1 Oct 2026 22:39:47 +0300 Subject: [PATCH] fix(persona): replace deprecated fetch_update with CAS loop in CallBudget The `try_acquire` method on `CallBudget` now uses a manual compare-and-swap loop instead of `fetch_update`, which has been deprecated on the latest stable Rust toolchain. The replacement avoids `try_update` as well, since that API is not available in the project's minimum supported Rust version. Auto-committed-on: dragonfly --- src/memory/persona/distill.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/memory/persona/distill.rs b/src/memory/persona/distill.rs index 565016b..3b6a6f3 100644 --- a/src/memory/persona/distill.rs +++ b/src/memory/persona/distill.rs @@ -85,9 +85,21 @@ impl CallBudget { /// Reserve one call, returning `false` once the budget is spent. Lock-free /// and correct under the concurrent `buffered` digest stream. fn try_acquire(&self) -> bool { - self.0 - .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |n| n.checked_sub(1)) - .is_ok() + // CAS loop rather than `fetch_update`/`try_update`: the former is + // deprecated on the newest stable, the latter is not in our MSRV. + let mut current = self.0.load(Ordering::SeqCst); + loop { + let Some(next) = current.checked_sub(1) else { + return false; + }; + match self + .0 + .compare_exchange_weak(current, next, Ordering::SeqCst, Ordering::SeqCst) + { + Ok(_) => return true, + Err(actual) => current = actual, + } + } } /// Calls still available in this run.