Skip to content

Clarify semantics of size-preserving transmutes#2911

Merged
jswrenn merged 1 commit intomainfrom
G64ec124d566c828ea61e6edf831a10338aa4c879
Jan 22, 2026
Merged

Clarify semantics of size-preserving transmutes#2911
jswrenn merged 1 commit intomainfrom
G64ec124d566c828ea61e6edf831a10338aa4c879

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Jan 22, 2026

Makes progress on #2701, #1940, #1852


Latest Update: v6 — Compare vs v5

📚 Full Patch History

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

Version v5 v4 v3 v2 v1 Base
v6 vs v5 vs v4 vs v3 vs v2 vs v1 vs Base
v5 vs v4 vs v3 vs v2 vs v1 vs 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

@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 significantly clarifies the semantic rules and safety guarantees for size-preserving pointer transmutes within the pointer::transmute module. The changes aim to provide a more precise understanding of how these transmutes operate, particularly by detailing the role of the SizeEq trait and its associated CastFrom type, and by tightening the conditions for validity to prevent unsafe shrinking or overwriting operations.

Highlights

  • Clarified Transmute Mechanism: The documentation now explicitly states that size-preserving transmutes are performed using <Dst as SizeEq<Src>>::CastFrom::project, providing a more precise definition of the underlying mechanism.
  • Refined Validity Conditions: The 'Reverse transmutation' precondition has been enhanced to clearly ban shrinking or overwriting transmutes by specifying that the set of DV-valid referents of dst must be a subset of the SV-valid referents of src.
  • Simplified Safety Proofs: The internal documentation explaining the soundness proof for transmutes has been refactored and simplified, making it more concise and directly referencing the invariants of the SizeEq trait.
  • Improved SizeEq Trait Documentation: The SizeEq trait now includes a comprehensive description of its purpose, explaining its role in enabling size-preserving casts or conversions. Its safety requirements have also been simplified to focus solely on the CastFrom associated type's responsibility to preserve referent size.

🧠 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 changed the title [WIP] Clarify semantics of size-preserving tranasmutes Clarify semantics of size-preserving tranasmutes Jan 22, 2026
@joshlf joshlf force-pushed the G64ec124d566c828ea61e6edf831a10338aa4c879 branch from 6b22f50 to 22b998f Compare January 22, 2026 20:38
@joshlf joshlf requested a review from jswrenn January 22, 2026 20:39
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 provides excellent clarifications to the documentation and safety comments related to size-preserving transmutes in src/pointer/transmute.rs. The changes significantly improve the clarity and correctness of the semantics, especially around the SizeEq trait and the conditions for sound transmutations. The refactoring of the safety proofs makes them more concise and easier to follow. Overall, these are high-quality improvements that enhance the maintainability and understandability of the code.

@joshlf joshlf changed the title Clarify semantics of size-preserving tranasmutes Clarify semantics of size-preserving transmutes Jan 22, 2026
@joshlf joshlf force-pushed the G64ec124d566c828ea61e6edf831a10338aa4c879 branch 2 times, most recently from b65b2c0 to d3d7fbd Compare January 22, 2026 20:47
Makes progress on #2701, #1940, #1852

gherrit-pr-id: G64ec124d566c828ea61e6edf831a10338aa4c879
@joshlf joshlf force-pushed the G64ec124d566c828ea61e6edf831a10338aa4c879 branch from d3d7fbd to eb8f348 Compare January 22, 2026 20:57
@jswrenn jswrenn enabled auto-merge January 22, 2026 21:01
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.90%. Comparing base (6aae3de) to head (eb8f348).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2911   +/-   ##
=======================================
  Coverage   91.90%   91.90%           
=======================================
  Files          20       20           
  Lines        5877     5879    +2     
=======================================
+ Hits         5401     5403    +2     
  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.

@jswrenn jswrenn added this pull request to the merge queue Jan 22, 2026
Merged via the queue into main with commit d6fd7f3 Jan 22, 2026
105 of 124 checks passed
@jswrenn jswrenn deleted the G64ec124d566c828ea61e6edf831a10338aa4c879 branch January 22, 2026 21:44
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