Tracking Issue for generic `Atomic`
Nobody has claimed this yet.
- 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
- ACP: https://github.com/rust-lang/libs-team/issues/443
- Implement
Atomic<T>as an alias toAtomicT: https://github.com/rust-lang/rust/pull/136316 - Flip alias so
AtomicTis an alias toAtomic<T>: #153015 - Move generic functionality from
AtomicTtoAtomic<_>-
new/into_inner/from_ptr/as_ptr/Default/From<T>: #153407
-
- Pseudo-prerequisite: Stabilize 128-bit atomics: https://github.com/rust-lang/rust/issues/99069
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
Atomic<T>is soft-blocked on 128-bit atomics, because since trait implementations cannot be unstable, gatingAtomic<i128>separately fromAtomic<i32>isn't possible.- If necessary,
AtomicI128could instead nameAtomic<Wrapper<i128>>for some unstable nameWrapperuntil 128-bit atomics are stable, to preventAtomic<i128>from being usable from stable earlier than intended.
- If necessary,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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