Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Jan 26, 2026

gherrit-pr-id: G63760a8d470a5ba5c4e99c01378403e191e05977
@joshlf joshlf marked this pull request as draft January 26, 2026 22:00
@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 foundational traits and a new projection mechanism to enable more flexible and type-safe field access through 'transparent wrapper' types. By defining Wrapped and HasWrappedField traits, the system can now understand how to unwrap types and project into their inner fields, even when those fields are themselves wrapped. This culminates in the project_wrapped method on Ptr, allowing direct field projection through these layers of abstraction, improving ergonomics and capability for complex data structures.

Highlights

  • New Traits for Transparent Wrappers: Introduced Wrapped trait for types that transparently wrap an inner type, and HasWrappedField for wrappers whose inner type contains a specific field.
  • Advanced Projection Mechanism: Defined WrappedProjection type alias to facilitate complex projections by chaining casts and field projections through transparent wrappers.
  • New Ptr Method for Wrapped Projections: Added the project_wrapped method to the Ptr struct, enabling direct projection of fields from an inner type even when the Ptr points to a transparent wrapper.
  • Updated Imports: Modified src/pointer/ptr.rs to import the newly defined traits (HasWrappedField, Wrapped) and TransmuteFrom for the new functionality.

🧠 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 new traits Wrapped and HasWrappedField, along with a WrappedProjection type alias in src/pointer/mod.rs. It also adds a new public function project_wrapped in src/pointer/ptr.rs to leverage these new abstractions. The changes aim to support projections inside transparent wrappers.

During the review, I found a critical missing safety justification in an unsafe block and a large commented-out code block that should be addressed for clarity and maintainability.

I::Validity,
>,
{
// SAFETY: TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The SAFETY: TODO comment indicates that the safety justification for this unsafe block is missing. All unsafe code must have a detailed explanation of why it is safe, covering all preconditions and postconditions. Please provide a comprehensive safety comment here.

Comment on lines +958 to +1002
// // FIXME(#196): Support all validity invariants (not just those that are
// // `CastableFrom`).
// #[must_use]
// #[inline(always)]
// pub fn project_wrapped<F, V, const FIELD_ID: i128, R>(
// self,
// ) -> Ptr<'a, T::WrappedField, (I::Aliasing, Unaligned, I::Validity)>
// where
// T: Wrapped
// + HasWrappedField<
// <<T as Wrapped>::Unwrapped as HasField<
// F,
// { crate::STRUCT_VARIANT_ID },
// FIELD_ID,
// >>::Type,
// >,
// T::Unwrapped: 'a
// + ProjectField<
// F,
// (I::Aliasing, Unaligned, V),
// { crate::STRUCT_VARIANT_ID },
// FIELD_ID,
// Invariants = (I::Aliasing, Unaligned, V),
// Error = core::convert::Infallible,
// >,
// T::Unwrapped: TransmuteFromPtr<T, I::Aliasing, I::Validity, V, R>,
// T::WrappedField: TransmuteFromPtr<
// <<T as Wrapped>::Unwrapped as HasField<
// F,
// { crate::STRUCT_VARIANT_ID },
// FIELD_ID,
// >>::Type,
// I::Aliasing,
// V,
// I::Validity,
// R,
// >,
// V: Validity,
// <T::Unwrapped as HasField<F, { crate::STRUCT_VARIANT_ID }, FIELD_ID>>::Type: 'a,
// {
// let inner = self.transmute_with::<T::Unwrapped, V, T::CastToUnwrapped, _>();
// let field_inner =
// crate::into_inner!(inner.project::<F, { crate::STRUCT_VARIANT_ID }, FIELD_ID>());
// field_inner.transmute_with::<T::WrappedField, _, <<T as HasWrappedField<_>>::WrappedField as Wrapped>::CastFromUnwrapped, _>()
// }
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, especially with a FIXME comment, suggests an incomplete feature or an alternative implementation that is not currently active. Commented-out code can clutter the codebase and make it harder to understand the active logic. If this code represents a future direction or an alternative approach, consider moving it to a separate branch, a design document, or removing it if it's no longer relevant. If it's temporarily commented out for debugging, please clarify its purpose and expected lifespan.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.05%. Comparing base (5fcf372) to head (a0fc1fb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/pointer/ptr.rs 0.00% 25 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2930      +/-   ##
==========================================
+ Coverage   91.31%   92.05%   +0.73%     
==========================================
  Files          20       19       -1     
  Lines        5897     5850      -47     
==========================================
  Hits         5385     5385              
+ Misses        512      465      -47     

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

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