Account for alignment directives in derive(IntoBytes)#3064
Account for alignment directives in derive(IntoBytes)#3064
derive(IntoBytes)#3064Conversation
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 enhances 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.
Code Review
This pull request aims to account for alignment directives on Dynamically Sized Types (DSTs) when deriving IntoBytes. The changes involve updating internal macros to accept alignment and packing parameters and modifying the procedural macro logic to extract and pass these values. While the overall direction is correct, there are several issues to address: the use of unwrap() in the procedural macro is risky and redundant, the current implementation causes a regression in MSRV tests due to how paths are passed to macros, and the use of TODO comments violates the repository's policy of using FIXME for non-blocking issues to avoid CI failures.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3064 +/- ##
=======================================
Coverage 91.87% 91.87%
=======================================
Files 20 20
Lines 6057 6057
=======================================
Hits 5565 5565
Misses 492 492 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
93d17cc to
1b397a6
Compare
1b397a6 to
0e20369
Compare
|
@joshlf This test: zerocopy/zerocopy-derive/src/output_tests/mod.rs Lines 248 to 278 in b7fc71d ...no longer passes, because the sub-tests no longer expand to the same thing (the different
|
Let's go with (1) – should be easy to get an agent to grind through it for you. |
derive(IntoBytes)derive(IntoBytes)
964c653 to
fd1fc83
Compare
This fixes #3063 by threading alignment directives into the padding check macros, and fixes #3067 by unconditionally emitting the padding check even in the absence of fields (thus ensuring that there exists a padding check into which alignment directives can be threaded). Fixes #3063, #3067 gherrit-pr-id: Gf18655827d1c30e4421c83579b962bf7aa453969
fd1fc83 to
ea77523
Compare
joshlf
left a comment
There was a problem hiding this comment.
Please address these before merging, but otherwise LGTM!
| #[macro_export] | ||
| macro_rules! struct_padding { | ||
| ($t:ty, [$($ts:ty),*]) => { | ||
| ($t:ty, $align:expr, $packed:expr, [$($ts:ty),*]) => {{ |
There was a problem hiding this comment.
| ($t:ty, $align:expr, $packed:expr, [$($ts:ty),*]) => {{ | |
| ($t:ty, $_align:expr, $_packed:expr, [$($ts:ty),*]) => {{ |
| #[macro_export] | ||
| macro_rules! union_padding { | ||
| ($t:ty, [$($ts:ty),*]) => {{ | ||
| ($t:ty, $align:expr, $packed:expr, [$($ts:ty),*]) => {{ |
There was a problem hiding this comment.
| ($t:ty, $align:expr, $packed:expr, [$($ts:ty),*]) => {{ | |
| ($t:ty, $_align:expr, $_packed:expr, [$($ts:ty),*]) => {{ |
| #[macro_export] | ||
| macro_rules! enum_padding { | ||
| ($t:ty, $disc:ty, $([$($ts:ty),*]),*) => {{ | ||
| ($t:ty, $align:expr, $packed:expr, $disc:ty, $([$($ts:ty),*]),*) => {{ |
There was a problem hiding this comment.
| ($t:ty, $align:expr, $packed:expr, $disc:ty, $([$($ts:ty),*]),*) => {{ | |
| ($t:ty, $_align:expr, $packed:expr, $disc:ty, $([$($ts:ty),*]),*) => {{ |
|
Mark #3072 (which releases 0.8.40) as merge-when-ready once this PR is in the merge queue? |
This fixes #3063 by threading alignment directives into the padding
check macros, and fixes #3067 by unconditionally emitting the padding
check even in the absence of fields (thus ensuring that there exists a
padding check into which alignment directives can be threaded).
Fixes #3063, #3067
derive(IntoBytes)#3064Latest Update: v7 — Compare vs v6
📚 Full Patch History
Links show the diff between the row version and the column version.
⬇️ Download this PR
Branch
git fetch origin refs/heads/Gf18655827d1c30e4421c83579b962bf7aa453969 && git checkout -b pr-Gf18655827d1c30e4421c83579b962bf7aa453969 FETCH_HEADCheckout
git fetch origin refs/heads/Gf18655827d1c30e4421c83579b962bf7aa453969 && git checkout FETCH_HEADCherry Pick
git fetch origin refs/heads/Gf18655827d1c30e4421c83579b962bf7aa453969 && git cherry-pick FETCH_HEADPull
Stacked PRs enabled by GHerrit.