rust-lang / rust-lang/rust

Tracking Issue for generic `Atomic`

Open
#130,539 9 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(generic_atomic)]

This is a tracking issue for replacing the distinct Atomic* types with a generic Atomic<T> type. This allows using Atomic with FFI type aliases and helps clean up some API surface. Only types with existing AtomicT are usable in Atomic<T>.

Public API
// core::sync::atomic

pub struct Atomic<T: AtomicPrimitive>(/* private fields*/);

pub type AtomicI32 = Atomic<i32>; // etc
Steps / History
Unresolved Questions
  • Atomic<T> is soft-blocked on 128-bit atomics, because since trait implementations cannot be unstable, gating Atomic<i128> separately from Atomic<i32> isn't possible.
    • If necessary, AtomicI128 could instead name Atomic<Wrapper<i128>> for some unstable name Wrapper until 128-bit atomics are stable, to prevent Atomic<i128> from being usable from stable earlier than intended.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the core::sync::atomic API described here and review the remaining work tracked by #153407, including the generic methods and conversions. Check the 128-bit atomic prerequisite in #99069 and the stabilization process documentation. Done means the remaining checklist items are resolved, unresolved questions are settled, and the feature reaches stabilization.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.