Skip to content

chore: Fix deprecation warnings for Atomic::fetch_update renamed to try_update #959

Description

@human-on-vm

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions