Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Jan 30, 2026


Latest Update: v4 β€” Compare vs v3

πŸ“š Full Patch History

Links show the diff between the row version and the column version.

Version v3 v2 v1 Base
v4 vs v3 vs v2 vs v1 vs Base
v3 vs v2 vs v1 vs Base
v2 vs v1 vs Base
v1 vs Base

Stacked PRs enabled by GHerrit.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @joshlf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the groundwork for a generic Atomic<T> type in Rust, allowing atomic operations on user-defined types. It establishes the necessary traits and macros to facilitate this functionality, starting with basic new, load, and store methods. This is a foundational step towards providing robust and safe concurrent data structures.

Highlights

  • Generic Atomic Type Introduction: Introduced a new generic Atomic<T> type, designed to enable atomic operations on arbitrary user-defined types T.
  • Trait Definitions for Atomic Behavior: Defined HasAtomic, AtomicSelector, and AtomicOps traits to abstract and standardize the behavior required for types to support atomic operations.
  • Standard Atomic Type Integration: Implemented AtomicOps for Rust's built-in atomic integer types (AtomicU8, AtomicU16, AtomicU32, AtomicU64) to bridge with the new generic Atomic<T>.
  • Macro for HasAtomic Implementation: Provided the impl_atomic! macro to simplify the process of implementing the HasAtomic trait for compatible types, reducing boilerplate.
  • Core Atomic Operations: Implemented fundamental atomic methods including new, load, and store for the Atomic<T> type, with placeholders for more advanced operations like swap and compare_exchange.
  • Comprehensive Unit Tests: Included a suite of unit tests to verify the correctness of Atomic<T> operations across various types, including u32, custom structs, and enums, as well as compare_exchange and fetch_update.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with πŸ‘ and πŸ‘Ž on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@joshlf joshlf force-pushed the Gc89c7a052aa2609ae71d4db8531f55dab2fd4306 branch 2 times, most recently from fdb9070 to 250475e Compare January 30, 2026 20:50
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Atomic<T> type. While this is a good start, the implementation is highly incomplete and not ready for merging. There are numerous TODO placeholders for documentation, safety justifications, and even core logic, which will cause panics at runtime. The unsafe traits and implementations lack the required safety comments, which is critical for a library focused on safety and a violation of the repository's contribution guidelines. Additionally, there's a large block of commented-out code that should be removed. The provided tests do not compile because the necessary trait implementations are missing. I recommend completing the implementation, adding all necessary documentation and safety justifications, and ensuring the tests pass before this can be considered for merging.

I am having trouble creating individual review comments. Click here to see my feedback.

src/atomic.rs (16-21)

critical

The public unsafe trait HasAtomic is missing documentation. It is critical to provide a detailed explanation of the trait's purpose and, most importantly, its safety contract in a /// # Safety section. This contract should clearly define the invariants that both implementors and callers must uphold to ensure memory safety.

References
  1. The repository style guide requires that every unsafe trait has /// # Safety documentation explaining its safety contract. (link)

src/atomic.rs (54-83)

critical

The unsafe impl blocks within the impl_atomic_selector! macro are missing their SAFETY comments (lines 56 and 77). Per the repository's guidelines, every unsafe implementation must be justified with a comment explaining why it is sound. Please add detailed // SAFETY: comments for the impl AtomicOps and impl AtomicSelector blocks.

References
  1. The repository style guide requires that every unsafe block has a // SAFETY: comment justifying its soundness. (link)

src/atomic.rs (92-111)

critical

The impl_atomic! macro is #[macro_export]-ed, but its implementation is incomplete, using todo!() for from_atomic and into_atomic. This will cause runtime panics. This functionality must be fully implemented. Additionally, the unsafe impl HasAtomic block is missing its required // SAFETY: comment explaining the soundness of the implementation.

References
  1. The repository style guide requires that every unsafe block has a // SAFETY: comment justifying its soundness. (link)

src/atomic.rs (142-143)

critical

This unsafe block is missing its required // SAFETY: comment. Please add a justification explaining why the call to T::from_atomic(v) is safe in this context. The comment should detail the invariants that make this operation sound.

References
  1. The repository style guide requires that every unsafe block has a // SAFETY: comment justifying its soundness. (link)

src/atomic.rs (34-52)

high

The doc(hidden) but public unsafe traits AtomicSelector and AtomicOps are missing their safety documentation. Even for hidden items, unsafe APIs must have a clearly documented safety contract.

References
  1. The repository style guide requires that every unsafe trait has /// # Safety documentation explaining its safety contract. (link)

src/atomic.rs (9)

medium

The module is missing documentation. Please add a module-level doc comment explaining the purpose and usage of the atomic module. Several other public items like Atomic<T> and its methods also have TODO placeholders instead of proper documentation.

src/atomic.rs (154-604)

medium

This large block of commented-out code should be removed. Dead code reduces maintainability and can be confusing for future contributors. If this code is being kept for reference, consider moving it to a separate document or tracking it in an issue.

gherrit-pr-id: Gc89c7a052aa2609ae71d4db8531f55dab2fd4306
@joshlf joshlf force-pushed the Gc89c7a052aa2609ae71d4db8531f55dab2fd4306 branch from 250475e to 92107ed Compare January 30, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant