Preserve nested DST padding in layout formulas - #3630
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3630 +/- ##
==========================================
- Coverage 91.85% 91.18% -0.68%
==========================================
Files 20 20
Lines 6093 6443 +350
==========================================
+ Hits 5597 5875 +278
- Misses 496 568 +72 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fe26d3863
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // SAFETY: By invariant on `self`, the size of `T` with this | ||
| // metadata is no larger than `isize::MAX`, and thus cannot | ||
| // overflow `usize`. | ||
| None => unsafe { core::hint::unreachable_unchecked() }, |
There was a problem hiding this comment.
Document the unchecked branch with the required citation
BLOCKING: This newly introduced unreachable_unchecked call is an unsafe block, but its safety comment lacks the versioned standard-library citation and quotation required by the repository's unsafe-review policy. Because reaching this arm is undefined behavior, add the relevant unreachable_unchecked safety text—for example, // [1] Per https://doc.rust-lang.org/1.92.0/std/hint/fn.unreachable_unchecked.html#safety: Reaching this function is Undefined Behavior.—and explicitly connect the MetadataOf and KnownLayout invariants to why size_for_metadata cannot return None.
AGENTS.md reference: zerocopy/AGENTS.md:L19-L23
Useful? React with 👍 / 👎.
050855d to
2f7ebd0
Compare
DstLayout flattened a nested slice DST's trailing-padding operation into the alignment of its packed outer container. That could understate the Rust object size, causing safe parsers and allocators to construct references and boxes whose referents extended beyond their backing storage. Represent slice-DST sizes as a normalized prefix plus an independently rounded inner size. Carry that formula through composition, padding, metadata inference, casts, projections, allocation, and split overlap checks. Add regressions for the reported 8-byte-versus-10-byte packed layout, parsing, allocation, zeroing, projection, metadata plateaus, and dynamic padding. Closes #3617 *Authored by an AI agent acting on Josh Liebow-Feeser's behalf.* gherrit-pr-id: Gxauzb34ce7e537xqailxsfsyzknfjcnl
2f7ebd0 to
3117a9b
Compare
DstLayout flattened a nested slice DST's trailing-padding operation into the
alignment of its packed outer container. That could understate the Rust object
size, causing safe parsers and allocators to construct references and boxes
whose referents extended beyond their backing storage.
Represent slice-DST sizes as a normalized prefix plus an independently rounded
inner size. Carry that formula through composition, padding, metadata
inference, casts, projections, allocation, and split overlap checks. Add
regressions for the reported 8-byte-versus-10-byte packed layout, parsing,
allocation, zeroing, projection, metadata plateaus, and dynamic padding.
Closes #3617
Authored by an AI agent acting on Josh Liebow-Feeser's behalf.
Latest Update: v6 — Compare vs v5
📚 Full Patch History
Links show the diff between the row version and the column version.
⬇️ Download this PR
Branch
git fetch origin refs/heads/Gxauzb34ce7e537xqailxsfsyzknfjcnl && git checkout -b pr-Gxauzb34ce7e537xqailxsfsyzknfjcnl FETCH_HEADCheckout
git fetch origin refs/heads/Gxauzb34ce7e537xqailxsfsyzknfjcnl && git checkout FETCH_HEADCherry Pick
git fetch origin refs/heads/Gxauzb34ce7e537xqailxsfsyzknfjcnl && git cherry-pick FETCH_HEADPull
Stacked PRs enabled by GHerrit.