rust: block: `allow(deprecated)` for `fetch_update` for Rust >= 1.99.0
Subsystems (3)
Miguel Ojeda
maintainerPATCH 1/1 rust: block: `allow(deprecated)` for `fetch_update` for Rust >= 1.99.0
Starting with Rust 1.99.0 (expected 2026-10-01), the Atomic*::fetch_update method is deprecated, with the compiler suggesting the try_update alias instead:
error: use of deprecated method `core::sync::atomic::Atomic::<u64>::fetch_update`: renamed to `try_update` for consistency
--> rust/kernel/block/mq/request.rs:206:22
|
206 | let old = target.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |x| Some(op(x)));
| ^^^^^^^^^^^^
|
= note: `-D deprecated` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(deprecated)]`
help: replace the use of the deprecated method
|
206 - let old = target.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |x| Some(op(x)));
206 + let old = target.try_update(Ordering::Relaxed, Ordering::Relaxed, |x| Some(op(x)));
|The deprecation was added in Rust 1.95.0 [1], but only triggers starting with Rust 1.99.0.
However, we cannot use the alias since our minimum in 6.12.y is Rust 1.78.0 -- try_update was added in Rust 1.86.0 [2].
Thus just allow the lint.
---
Warning: this is a 6.12.y-only patch -- I assume you prefer something local like this instead of backporting the commit that made this go away later with the move to Refcount.
rust/kernel/block/mq/request.rs | 2 ++ 1 file changed, 2 insertions(+)
rust/kernel/block/mq/request.rs +2 -0
@@ -203,6 +203,7 @@ unsafe impl<T: Operations> Sync for Request<T> {}/// Store the result of `op(target.load())` in target, returning new value of /// target. fn atomic_relaxed_op_return (target: &AtomicU64 , op:impl Fn (u64 ) ->u64 ) ->u64 { +#[allow(deprecated)] let old = target.fetch_update (Ordering ::Relaxed ,Ordering ::Relaxed , |x|Some (op (x)));// SAFETY: Because the operation passed to `fetch_update` above always
@@ -215,6 +216,7 @@ fn atomic_relaxed_op_return(target: &AtomicU64, op: impl Fn(u64) -> u64) -> u64/// Store the result of `op(target.load)` in `target` if `target.load() != /// pred`, returning [`true`] if the target was updated. fn atomic_relaxed_op_unless (target: &AtomicU64 , op:impl Fn (u64 ) ->u64 , pred:u64 ) ->bool { +#[allow(deprecated)] target .fetch_update (Ordering ::Relaxed ,Ordering ::Relaxed , |x| {if x == pred {
base-commit: 6c7577041b6a76ee4e18c3910bab12a268df037e --
2.55.0
Quoted 33 lines · Miguel Ojeda
Starting with Rust 1.99.0 (expected 2026-10-01), the
Atomic*::fetch_updatemethod is deprecated, with the compiler suggesting thetry_updatealias instead:error: use of deprecated method `core::sync::atomic::Atomic::<u64>::fetch_update`: renamed to `try_update` for consistency --> rust/kernel/block/mq/request.rs:206:22 | 206 | let old = target.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |x| Some(op(x))); | ^^^^^^^^^^^^ | = note: `-D deprecated` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(deprecated)]` help: replace the use of the deprecated method | 206 - let old = target.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |x| Some(op(x))); 206 + let old = target.try_update(Ordering::Relaxed, Ordering::Relaxed, |x| Some(op(x))); |The deprecation was added in Rust 1.95.0 [1], but only triggers starting with Rust 1.99.0.
However, we cannot use the alias since our minimum in 6.12.y is Rust 1.78.0 --
try_updatewas added in Rust 1.86.0 [2].Thus just allow the lint.
Cc Andreas Hindborg <[email protected]>Cc Boqun Feng <[email protected]>Cc Jens Axboe <[email protected]>Signed-off-by Miguel Ojeda <[email protected]>
Quoted 4 lines
---
Warning: this is a 6.12.y-only patch -- I assume you prefer something local like this instead of backporting the commit that made this go away later with the move toRefcount.
Cc'ing stable here in the reply.
Cheers,
Miguel
Quoted 5 lines
Quoted 3 lines
Warning: this is a 6.12.y-only patch -- I assume you prefer something local like this instead of backporting the commit that made this go away later with the move to
Refcount.Cc'ing stable here in the reply.
Queued for 6.12, thanks.
Signature · 2 lines
Thanks, Sasha