While compiling the xet-runtime, xet-client, and xet-data crates, the compiler emits multiple deprecation warnings regarding the use of std::sync::atomic::Atomic::<T>::fetch_update, which has been renamed to try_update for consistency.
Example warning:
warning: use of deprecated method `std::sync::atomic::Atomic::<u64>::fetch_update`: renamed to `try_update` for consistency
--> xet_runtime/src/utils/adjustable_semaphore.rs:322:13
|
322| match v.fetch_update(SeqCst, SeqCst, |x| {
| ^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
|
322| match v.try_update(SeqCst, SeqCst, |x| {
| ~~~~~~~~~~
Why this needs to be addressed
While these are currently just warnings and do not break the current build, leaving them unaddressed is not ideal for several reasons:
- Future Build Breakage: Deprecated methods are eventually removed from the standard library or underlying crates in future major/minor releases. If this code is not updated, it will turn into a hard compilation error in future Rust toolchain updates, breaking the build unexpectedly.
- Warning Fatigue: A noisy build output causes developers to ignore warnings. When the console is flooded with deprecation notices, it becomes much harder to spot critical warnings, such as actual logic bugs, security vulnerabilities, or unsafe code violations.
- CI/CD Pipeline Health: Many projects enforce strict linting in their CI pipelines (e.g., using
#![deny(warnings)] or cargo build --warnings-as-errors). Even if not strictly enforced, clean logs are essential for debugging and maintaining a healthy development environment.
- Code Modernization: Adopting the new
try_update API ensures the codebase aligns with the latest Rust naming conventions and consistency standards.
Proposed Solution
The compiler already provides the exact fix. We need to replace all instances of .fetch_update( with .try_update( in the affected files.
Alternatively, this can be fixed automatically by running the following command in the workspace root:
cargo fix --lib -p xet-runtime --allow-dirty
cargo fix --lib -p xet-client --allow-dirty
cargo fix --lib -p xet-data --allow-dirty
Affected Files (based on compiler output):
xet_runtime/src/utils/adjustable_semaphore.rs (Lines 322, 338)
xet_client/src/cas_client/adaptive_concurrency/controller.rs (Line 664)
xet_client/src/cas_client/telemetry/sink.rs (Line 133)
xet_data/src/progress_tracking/progress_types.rs (Lines 531, 542)
Environment
Observed during compilation in a Termux (Android) environment, but applies to all platforms/toolchains.
While compiling the
xet-runtime,xet-client, andxet-datacrates, the compiler emits multiple deprecation warnings regarding the use ofstd::sync::atomic::Atomic::<T>::fetch_update, which has been renamed totry_updatefor consistency.Example warning:
Why this needs to be addressed
While these are currently just warnings and do not break the current build, leaving them unaddressed is not ideal for several reasons:
#![deny(warnings)]orcargo build --warnings-as-errors). Even if not strictly enforced, clean logs are essential for debugging and maintaining a healthy development environment.try_updateAPI ensures the codebase aligns with the latest Rust naming conventions and consistency standards.Proposed Solution
The compiler already provides the exact fix. We need to replace all instances of
.fetch_update(with.try_update(in the affected files.Alternatively, this can be fixed automatically by running the following command in the workspace root:
Affected Files (based on compiler output):
xet_runtime/src/utils/adjustable_semaphore.rs(Lines 322, 338)xet_client/src/cas_client/adaptive_concurrency/controller.rs(Line 664)xet_client/src/cas_client/telemetry/sink.rs(Line 133)xet_data/src/progress_tracking/progress_types.rs(Lines 531, 542)Environment
Observed during compilation in a Termux (Android) environment, but applies to all platforms/toolchains.