Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Jan 23, 2026

Relax the preconditions on TryTransmuteFromPtr to permit any
address- and size-preserving cast, not just SizeEq::CastFrom. This
preserves the same safety semantics, but permits any C: CastExact cast
as the underlying cast. This will allow us to perform transmutes more
easily in situations where it is difficult to emit SizeEq impls, and
will generally allow us to reduce the number of SizeEq impls required
across the codebase.


Latest Update: v18 — Compare vs v17

📚 Full Patch History

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

Version 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 enhances the flexibility of pointer transmutation by relaxing the preconditions on the TryTransmuteFromPtr trait and introducing a more generic casting mechanism. By allowing any address- and size-preserving cast, the change simplifies the implementation of transmutes and reduces the need for numerous SizeEq trait implementations, ultimately streamlining the codebase while maintaining the existing safety guarantees.

Highlights

  • Relaxed TryTransmuteFromPtr Preconditions: The TryTransmuteFromPtr unsafe trait no longer requires the SizeEq<Src> super-trait bound, making it more flexible for various casting scenarios.
  • Generalized Transmutation Mechanism: A new transmute_with method has been introduced to the Ptr type, allowing any C: CastExact (address- and size-preserving) cast to be specified for transmutation, rather than being restricted to SizeEq::CastFrom.
  • Refactored Ptr::transmute: The existing Ptr::transmute method now delegates to the new transmute_with method, using <U as SizeEq<T>>::CastFrom as its default cast, ensuring backward compatibility while leveraging the new generic mechanism.
  • Updated Safety Comments and Documentation: Safety comments and documentation across the relevant files have been updated to reflect the more general CastExact trait and the concept of 'address- and size-preserving casts', improving clarity and accuracy.

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

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.91%. Comparing base (c358fd5) to head (ed4b47f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2920   +/-   ##
=======================================
  Coverage   91.90%   91.91%           
=======================================
  Files          20       20           
  Lines        5883     5890    +7     
=======================================
+ Hits         5407     5414    +7     
  Misses        476      476           

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

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 successfully refactors the transmute functionality by introducing a more generic transmute_with method and removing the SizeEq super-trait bound from TryTransmuteFromPtr. This change enhances flexibility by allowing any CastExact type for address- and size-preserving casts, aligning with the goal of reducing SizeEq implementations across the codebase. The safety comments and documentation have been updated to reflect these changes accurately.

Relax the preconditions on `TryTransmuteFromPtr` to permit *any*
address- and size-preserving cast, not just `SizeEq::CastFrom`. This
preserves the same safety semantics, but permits any `C: CastExact` cast
as the underlying cast. This will allow us to perform transmutes more
easily in situations where it is difficult to emit `SizeEq` impls, and
will generally allow us to reduce the number of `SizeEq` impls required
across the codebase.

gherrit-pr-id: G0973aa3261bb811a53f7d99b8d38df5d6c328d52
@joshlf joshlf force-pushed the G0973aa3261bb811a53f7d99b8d38df5d6c328d52 branch from dd3f8d1 to ed4b47f Compare January 26, 2026 04: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.

2 participants