Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Jan 16, 2026

Remove high-level HasField::project_inner, and rename
HasField::project_raw to HasField::project.

The new plan is for pointer::cast::Project and HasField to only have
project methods which project from PtrInner<Src> to *mut Dst, and
for callers who want PtrInner -> PtrInner or Ptr -> Ptr to use
inherent methods on PtrInner and Ptr. Compared to a default-impl'd
method on HasField, this reduces indirection and reduces pressure on
the optimizer.

Reverts #2884, #2885


Latest Update: v9 — Compare vs v8

📚 Full Patch History

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

Version 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 refactors the projection mechanisms within the zerocopy crate, focusing on simplifying the HasField and pointer::cast::Project traits. By removing a redundant high-level projection method and standardizing the primary project method to return raw mutable pointers, the change aims to create a more direct and efficient API. This approach delegates more complex pointer transformations to inherent methods on PtrInner and Ptr, thereby reducing indirection and potentially improving optimizer performance.

Highlights

  • API Simplification: The high-level HasField::project_inner method has been removed to streamline the API.
  • Method Renaming: The HasField::project_raw method has been renamed to HasField::project for consistency and clarity.
  • Standardized Projection Output: Both pointer::cast::Project and HasField traits now exclusively feature project methods that return raw mutable pointers (*mut Dst), simplifying the core projection mechanism.
  • Improved Performance and Reduced Indirection: Higher-level pointer transformations (e.g., PtrInner -> PtrInner or Ptr -> Ptr) are now handled by inherent methods on PtrInner and Ptr, reducing indirection and optimizing code generation.
  • Reversion of Previous Changes: This pull request reverts changes introduced in Rename HasField::project to HasField::project_raw #2884 and Introduce HasField::project_inner #2885, indicating a refinement of the projection strategy.

🧠 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 simplifies projection methods by removing the high-level HasField::project_inner method and renaming HasField::project_raw to HasField::project. The logic from project_inner is now part of inherent methods on PtrInner and Ptr, which reduces indirection. I have reviewed the changes across all modified files, including the trait definitions, implementations, and derive macros. The refactoring has been applied consistently and correctly. The renames are complete, and the removal of project_inner is compensated by the new logic in PtrInner::project. The changes are sound and improve the API's clarity. I have not found any issues.

@codecov-commenter
Copy link

codecov-commenter commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.90%. Comparing base (709b5b2) to head (a8b0bbc).

Files with missing lines Patch % Lines
src/impls.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2895      +/-   ##
==========================================
+ Coverage   91.82%   91.90%   +0.07%     
==========================================
  Files          20       20              
  Lines        5883     5878       -5     
==========================================
  Hits         5402     5402              
+ Misses        481      476       -5     

☔ 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 G481927cb6e9ca76c1531c05465f608e1b2607a62 branch 2 times, most recently from ccfcfc0 to 897a5a3 Compare January 16, 2026 22:54
Base automatically changed from G2eb58496ed1e3c61421020abbbb694d970d43c1c to main January 16, 2026 23:20
Remove high-level `HasField::project_inner`, and rename
`HasField::project_raw` to `HasField::project`.

The new plan is for `pointer::cast::Project` and `HasField` to only have
`project` methods which project from `PtrInner<Src>` to `*mut Dst`, and
for callers who want `PtrInner -> PtrInner` or `Ptr -> Ptr` to use
inherent methods on `PtrInner` and `Ptr`. Compared to a default-impl'd
method on `HasField`, this reduces indirection and reduces pressure on
the optimizer.

Reverts #2884, #2885

gherrit-pr-id: G481927cb6e9ca76c1531c05465f608e1b2607a62
@joshlf joshlf force-pushed the G481927cb6e9ca76c1531c05465f608e1b2607a62 branch from 897a5a3 to a8b0bbc Compare January 16, 2026 23:57
@joshlf joshlf enabled auto-merge January 16, 2026 23:57
@joshlf joshlf added this pull request to the merge queue Jan 17, 2026
Merged via the queue into main with commit 0f16595 Jan 17, 2026
104 of 122 checks passed
@joshlf joshlf deleted the G481927cb6e9ca76c1531c05465f608e1b2607a62 branch January 17, 2026 00:37
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.

3 participants