-
Notifications
You must be signed in to change notification settings - Fork 139
[WIP][derive] Use ReadOnly in is_bit_valid #2874
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: G7691845b6b02e9f3d9578435d732bacfa6ca674f
Are you sure you want to change the base?
[WIP][derive] Use ReadOnly in is_bit_valid #2874
Conversation
Introduce `CastExact: Cast`, which denotes that a `Cast` exactly preserves the set of referent bytes. Add this bound to `SizeEq::CastFrom`, allowing `SizeEq` to be safe to implement. gherrit-pr-id: G57ec07c3841271440bbaf40cab04b942cbdbddb9
Previously, we allowed for `Src: Read<A, R>` and `Dst: Read<A, S>` for different `R` and `S` "reason" parameters. This is an unnecessary degree of freedom (two types are only ever `Read<A>` for a particular `A` for the same reason – either because `A = Exclusive` or because both types implement `Immutable`). This degree of freedom required more verbose type annotations by callers. gherrit-pr-id: Gbec926233303ce55c894f8ba65c939dd42690530
gherrit-pr-id: Gbe8d7edd150d80731c79815685c596ed88460ae7
gherrit-pr-id: G7691845b6b02e9f3d9578435d732bacfa6ca674f
gherrit-pr-id: G6cefafff5fb576d45dbb1a303780ca47c3ea03e5
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 focuses on refactoring 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. 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 refactors the is_bit_valid derive logic to use ReadOnly and a new WrappedProjection mechanism. This improves safety by removing an unsafe block in zerocopy-derive/src/enum.rs and makes the projection logic more consistent across the derive implementations. The changes look good, but there are a few places where the old code has been commented out. These should be removed to improve code clarity.
| // let tag_ptr = raw_enum.reborrow().project::< | ||
| // (), | ||
| // { #zerocopy_crate::ident_id!(tag) } | ||
| // >() |
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.
| WrappedProjection<_, _, { #zerocopy_crate::STRUCT_VARIANT_ID }, { #zerocopy_crate::ident_id!(variants) }>, | ||
| _, | ||
| >(); | ||
| // let variants = raw_enum.project::<_, { #zerocopy_crate::ident_id!(variants) }>(); |
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.
| // let field_candidate = candidate.reborrow().project::< | ||
| // _, | ||
| // { #zerocopy_crate::ident_id!(#field_names) } | ||
| // >(); |
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.
e6fab2d to
6a4dcd8
Compare
Uh oh!
There was an error while loading. Please reload this page.