-
Notifications
You must be signed in to change notification settings - Fork 138
[WIP] Introduce TryFromBytes::Uninit
#3021
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: Gc3e9ee9afa6945e10c35be84d30c970894395c96
Are you sure you want to change the base?
[WIP] Introduce TryFromBytes::Uninit
#3021
Conversation
Summary of ChangesHello @jswrenn, 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 lays the groundwork for more precise handling of uninitialized memory within the 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. Changelog
Activity
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 a new associated type Uninit to the TryFromBytes trait, which is a significant step towards more fine-grained validity tracking. The changes propagate this new type through various trait implementations and macros. My review focuses on a few places where the Uninit type is being set to a default placeholder but should instead be inherited from an inner or representation type. These changes will improve the correctness of the new validity system.
src/util/macros.rs
Outdated
| // TODO: Audit this `Uninit` | ||
| type Uninit = crate::invariant::Uninit; |
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.
The Uninit associated type for a type that is TransmuteFrom<Repr> should be inherited from its representation Repr. Currently, it's hardcoded to crate::invariant::Uninit, which is incorrect if Repr has a more complex Uninit type (e.g., if it's a tuple).
| // TODO: Audit this `Uninit` | |
| type Uninit = crate::invariant::Uninit; | |
| type Uninit = <$repr as $crate::TryFromBytes>::Uninit; |
src/wrappers.rs
Outdated
| // TODO: Is this the `Uninit` we want here? | ||
| type Uninit = crate::invariant::Uninit; |
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.
Since Unalign<T> has the same bit validity as T and its is_bit_valid implementation delegates to T, its Uninit associated type should also be inherited from T.
| // TODO: Is this the `Uninit` we want here? | |
| type Uninit = crate::invariant::Uninit; | |
| type Uninit = <T as crate::TryFromBytes>::Uninit; |
src/wrappers.rs
Outdated
| // TODO: Is this the `Uninit` we want here? | ||
| type Uninit = crate::invariant::Uninit; |
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.
ReadOnly<T> is a transparent wrapper, and its is_bit_valid implementation delegates to T. Therefore, its Uninit associated type should be inherited from T as well.
| // TODO: Is this the `Uninit` we want here? | |
| type Uninit = crate::invariant::Uninit; | |
| type Uninit = <T as crate::TryFromBytes>::Uninit; |
gherrit-pr-id: Geec83fc8d47be6b2e51a15b84a2735bbc909ce68
3696111 to
7460ab3
Compare
TryFromBytes::Uninit#3021Ptr::project_map#2984Ptrvalidity #2966Latest Update: v3 — Compare vs v2
📚 Full Patch History
Links show the diff between the row version and the column version.
⬇️ Download this PR
Branch
git fetch origin refs/heads/Geec83fc8d47be6b2e51a15b84a2735bbc909ce68 && git checkout -b pr-Geec83fc8d47be6b2e51a15b84a2735bbc909ce68 FETCH_HEADCheckout
git fetch origin refs/heads/Geec83fc8d47be6b2e51a15b84a2735bbc909ce68 && git checkout FETCH_HEADCherry Pick
git fetch origin refs/heads/Geec83fc8d47be6b2e51a15b84a2735bbc909ce68 && git cherry-pick FETCH_HEADPull
Stacked PRs enabled by GHerrit.