-
Notifications
You must be signed in to change notification settings - Fork 137
[WIP] Projection inside transparent wrappers #2930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
gherrit-pr-id: G63760a8d470a5ba5c4e99c01378403e191e05977
Summary of ChangesHello @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 Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // // 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, _>() | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Uh oh!
There was an error while loading. Please reload this page.