Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Jan 7, 2026


Latest Update: v19 — Compare vs v18

📚 Full Patch History

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

Version v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v19 v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v18 v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v17 v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v16 v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v8 v7 v6 v5 v4 v3 v2 v1 Base
v7 v6 v5 v4 v3 v2 v1 Base
v6 v5 v4 v3 v2 v1 Base
v5 v4 v3 v2 v1 Base
v4 v3 v2 v1 Base
v3 v2 v1 Base
v2 v1 Base
v1 Base

@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 introduces a significant refactoring to consistently use ReadOnly views when performing bit validity checks across the codebase. By updating the Maybe type alias and modifying various macros and trait implementations, the change ensures that is_bit_valid functions operate on immutable data, enhancing type safety and correctness. This also streamlines the implementation of validity checks for types like UnsafeCell and atomic types, making the system more robust.

Highlights

  • is_bit_valid Refactoring: The is_bit_valid function for UnsafeCell<T> and within the impl_for_transmute_from! macro has been simplified to directly use candidate.transmute() instead of into_exclusive_or_pme() and get_mut().
  • Maybe Type Alias Update: The Maybe type alias, which defines the argument type for TryFromBytes::is_bit_valid, now uses ReadOnly<T> instead of T, ensuring that bit validity checks operate on immutable views.
  • Macro Enhancements for ReadOnly: The impl_size_eq! and unsafe_impl_for_transparent_wrapper! macros have been extended to correctly handle ReadOnly types, including new SizeEq implementations and casting mechanisms.
  • Atomic Type Trait Refinement: The macros for implementing traits for atomic types have been split into impl_layout_traits_for_atomics! and impl_validity_traits_for_atomics!, providing a clearer separation of concerns for layout and validity traits, and incorporating the new impl_size_eq! syntax.

🧠 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.

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 ReadOnly wrapper to the Maybe type alias, which is used in is_bit_valid checks. This is a significant safety improvement, as it enforces at the type level that these checks do not perform mutations. The changes correctly propagate this new approach through various macros and implementations, and the refactoring of some macros for better clarity is appreciated. My review focuses on cleaning up some leftover commented-out code from this refactoring effort.

src/impls.rs Outdated
Comment on lines 866 to 887
// // The only way to implement this function is using an exclusive-aliased
// // pointer. `UnsafeCell`s cannot be read via shared-aliased pointers
// // (other than by using `unsafe` code, which we can't use since we can't
// // guarantee how our users are accessing or modifying the `UnsafeCell`).
// //
// // `is_bit_valid` is documented as panicking or failing to monomorphize
// // if called with a shared-aliased pointer on a type containing an
// // `UnsafeCell`. In practice, it will always be a monomorphization error.
// // Since `is_bit_valid` is `#[doc(hidden)]` and only called directly
// // from this crate, we only need to worry about our own code incorrectly
// // calling `UnsafeCell::is_bit_valid`. The post-monomorphization error
// // makes it easier to test that this is truly the case, and also means
// // that if we make a mistake, it will cause downstream code to fail to
// // compile, which will immediately surface the mistake and give us a
// // chance to fix it quickly.
// let c = candidate.into_exclusive_or_pme();

// // SAFETY: Since `UnsafeCell<T>` and `T` have the same layout and bit
// // validity, `UnsafeCell<T>` is bit-valid exactly when its wrapped `T`
// // is. Thus, this is a sound implementation of
// // `UnsafeCell::is_bit_valid`.
// T::is_bit_valid(c.get_mut())
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This large block of commented-out code appears to be the old implementation. To improve readability and maintainability, it would be great to remove it before this pull request is merged.

Comment on lines 524 to 590
// /// `Ptr<'a, T, (_, _, _)>` → `Ptr<'a, ReadOnly<T>, (_, _, _)>`
// impl<'a, T, I> Ptr<'a, T, I>
// where
// T: ?Sized,
// I: Invariants,
// {
// /// TODO
// pub(crate) fn into_read_only<R>(
// self,
// ) -> Ptr<'a, crate::ReadOnly<T>, (I::Aliasing, I::Alignment, I::Validity)>
// where
// T: Read<I::Aliasing, R>,
// {
// let ro = self.transmute::<_, _, (_, _)>();
// unsafe { ro.assume_alignment() }
// }
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This commented-out implementation of into_read_only seems to be unused. To keep the codebase clean, it would be best to remove it if it's not part of this change.

let ptr: Ptr<'_, Dst, _> = ptr.cast::<_, crate::pointer::cast::CastSized, _>();

if Dst::is_bit_valid(ptr.forget_aligned()) {
if Dst::is_bit_valid(ptr.transmute::<_, _, (_, (_, BecauseExclusive))>().forget_aligned()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The call to .forget_aligned() here seems redundant. The transmute() method on Ptr already returns a Ptr with Unaligned alignment, so forget_aligned() is a no-op in this context. Removing it would make the code slightly cleaner.

Suggested change
if Dst::is_bit_valid(ptr.transmute::<_, _, (_, (_, BecauseExclusive))>().forget_aligned()) {
if Dst::is_bit_valid(ptr.transmute::<_, _, (_, (_, BecauseExclusive))>()) {

fn is_bit_valid<A: crate::pointer::invariant::Reference>(candidate: Maybe<'_, Self, A>) -> bool {
let c: Maybe<'_, Self, crate::pointer::invariant::Exclusive> = candidate.into_exclusive_or_pme();
let c: Maybe<'_, $repr, _> = c.transmute::<_, _, (_, (_, BecauseExclusive))>();
// let c: Maybe<'_, Self, crate::pointer::invariant::Exclusive> = candidate.into_exclusive_or_pme();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This commented-out line can be removed to clean up the code.

src/wrappers.rs Outdated
Comment on lines 674 to 690
// enum BecauseReadOnly {}

// /// Denotes that `src: Ptr<Src, (A, _, SV)>` and `dst: Ptr<Self, (A, _, DV)>`,
// /// referencing the same referent at the same time, cannot be used by safe code
// /// to break library safety invariants of `Src` or `Self`.
// ///
// /// # Safety
// ///
// /// At least one of the following must hold:
// /// - `Src: Read<A, _>` and `Self: Read<A, _>`
// /// - `Self: InvariantsEq<Src>`, and, for some `V`:
// /// - `Dst: TransmuteFrom<Src, V, V>`
// /// - `Src: TransmuteFrom<Dst, V, V>`

// // SAFETY: TODO
// unsafe impl<T: ?Sized, A: Aliasing, V> MutationCompatible<T, A, V, V, BecauseReadOnly>
// for ReadOnly<T>
// {
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This block of commented-out code seems to be a work-in-progress idea. If it's not intended to be part of this pull request, it would be best to remove it to avoid cluttering the codebase.

@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from 81ada6e to a353963 Compare January 7, 2026 23:08
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from ad978ce to ee75641 Compare January 7, 2026 23:08
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch 3 times, most recently from 09a6d35 to 6ac888a Compare January 8, 2026 14:21
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 94.59459% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (Gbe8d7edd150d80731c79815685c596ed88460ae7@3c09949). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/macros.rs 0.00% 2 Missing ⚠️
src/util/macros.rs 66.66% 2 Missing ⚠️
Additional details and impacted files
@@                             Coverage Diff                              @@
##             Gbe8d7edd150d80731c79815685c596ed88460ae7    #2873   +/-   ##
============================================================================
  Coverage                                             ?   91.51%           
============================================================================
  Files                                                ?       20           
  Lines                                                ?     5919           
  Branches                                             ?        0           
============================================================================
  Hits                                                 ?     5417           
  Misses                                               ?      502           
  Partials                                             ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from ee75641 to 6539cee Compare January 8, 2026 15:26
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from 6ac888a to 1b4834d Compare January 8, 2026 15:26
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from 6539cee to e2f1bc3 Compare January 8, 2026 15:36
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch 2 times, most recently from c83b71f to db5ec29 Compare January 8, 2026 15:58
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from e2f1bc3 to 45ff87c Compare January 8, 2026 15:58
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from db5ec29 to 845c5e7 Compare January 8, 2026 16:54
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from 45ff87c to d1f62db Compare January 8, 2026 19:34
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch 3 times, most recently from b6642a7 to d0f57ea Compare January 8, 2026 19:50
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from d1f62db to 65f15b8 Compare January 8, 2026 19:50
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from 65f15b8 to 318b671 Compare January 9, 2026 00:00
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from d0f57ea to 6cbe1ca Compare January 9, 2026 00:00
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from 318b671 to 9230a53 Compare January 9, 2026 16:57
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from 6cbe1ca to 5cf70a2 Compare January 9, 2026 16:57
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from 5cf70a2 to e6fab2d Compare January 9, 2026 17:04
gherrit-pr-id: G7691845b6b02e9f3d9578435d732bacfa6ca674f
@joshlf joshlf force-pushed the G7691845b6b02e9f3d9578435d732bacfa6ca674f branch from e6fab2d to 6a4dcd8 Compare January 9, 2026 17:22
@joshlf joshlf force-pushed the Gbe8d7edd150d80731c79815685c596ed88460ae7 branch from 9230a53 to 3c09949 Compare January 9, 2026 17:22
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.

2 participants