-
Notifications
You must be signed in to change notification settings - Fork 139
Generate trait implementations for tuples #2862
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
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 significantly extends the utility of 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 introduces trait implementations for tuples up to size 26, which is a valuable addition. The implementation uses a complex but well-structured macro. The refactoring of is_bit_valid logic into a helper function is_field_valid is a good improvement for maintainability. I've found one critical issue in the derive macro that will cause compilation failures for users and needs to be addressed.
489515e to
96eb35c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2862 +/- ##
========================================
Coverage 91.89% 91.90%
========================================
Files 20 20
Lines 5773 5878 +105
========================================
+ Hits 5305 5402 +97
- Misses 468 476 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
96eb35c to
96cb8ae
Compare
96cb8ae to
8db8380
Compare
8db8380 to
8303c30
Compare
| >(); | ||
|
|
||
| <#field_tys as #zerocopy_crate::TryFromBytes>::is_bit_valid(field_candidate) | ||
| #zerocopy_crate::TryFromBytes::is_bit_valid(field_candidate) |
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.
It may be slightly more robust/reliable to keep the <#field_tys as ...> syntax since it makes the self type completely unambiguous. Currently not a problem, but I could theoretically see this becoming an issue if we ever change the signature of is_bit_valid to something that makes the type inference ambiguous (or worse, makes it infer as the wrong function so this silently compiles but is unsound).
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.
I think the risk is negligible and outweighed by clarity benefits of removing a turbofish. The type of field_candidate flows directly from projection. The salient soundness condition of is_bit_valid is that every field is validated (and so we splat over #field_names); not that projection is correct. I agree that projection being incorrect would cause a soundness issue, but it'd be silly to program defensively on the assumption that project has confused the field type. And if projection is sound, there cannot be any ambiguity, since the field type is an associated type of HasField, not a parameter.
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.
And I think we should apply this guiding principle to most other parts of our codebase. Like here, why are we programming defensively against cast returning the wrong type?
zerocopy/zerocopy-derive/src/enum.rs
Lines 343 to 350 in 4cfb5c9
| let variant = variant_md.cast::< | |
| #variant_struct_ident #ty_generics, | |
| #zerocopy_crate::pointer::cast::CastSized, | |
| #zerocopy_crate::pointer::BecauseInvariantsEq | |
| >(); | |
| < | |
| #variant_struct_ident #ty_generics as #trait_path | |
| >::is_bit_valid(variant) |
Emit implementations of `HasField`, `Immutable`, `TryFromBytes`, `FromZeros`, and `FromBytes` for tuples of length up to 26. Closes #274 gherrit-pr-id: G992a50c1ccf344487e1cd764afe0b17e566bc620
8303c30 to
42a6251
Compare
Emit implementations of
HasField,Immutable,TryFromBytes,FromZeros, andFromBytesfor tuples of length up to 26.Closes #274
Latest Update: v6 — Compare vs v5
📚 Full Patch History
Links show the diff between the row version and the column version.