Remove the pre-Rust-1.79 raw-slice metadata fallback once the MSRV permits `ptr.len()`
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 179
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 29
Description
## Summary
#3629 fixes #3615 while preserving the Rust 1.56 MSRV. Before Rust 1.79, it
extracts raw-slice metadata using the historical raw-pointer `Hash`
implementation, treats the result only as a candidate, reconstructs a raw
slice, and authenticates the candidate with raw-pointer equality before
returning it.
Once zerocopy’s MSRV is at least Rust 1.79, remove that fallback and use raw
slice pointer `.len()` unconditionally.
This issue does not propose raising the MSRV. It tracks cleanup after an
independently approved MSRV increase.
## Motivation
Rust 1.79 stabilized raw slice pointer `.len()`. Its contract directly supplies
the capability `KnownLayout::pointer_to_metadata` needs: reading slice metadata
without dereferencing the pointer or requiring it to be non-null, aligned,
live, or dereferenceable.
The fail-closed compatibility fallback carries a larger proof and maintenance
surface:
- reliance on the historical raw-pointer `Hash` decomposition;
- a purpose-built `MetadataHasher`;
- raw-slice reconstruction and candidate authentication with `ptr::eq`;
- assertion paths for an unexpected hashing implementation; and
- a dedicated build cfg and CI boundary-toolchain case.
After every supported toolchain has `.len()`, this is unnecessary TCB and
configuration complexity.
## Work
- [ ] Replace conditional `<[T] as KnownLayout>::pointer_to_metadata` with
unconditional `ptr.len()`.
- [ ] Remove `MetadataHasher`, the historical `Hash` proof, reconstruction,
authentication, and fallback assertions.
- [ ] Remove `no_zerocopy_slice_ptr_len_1_79_0` from `zerocopy/Cargo.toml`.
- [ ] Remove its dedicated boundary-toolchain entries from CI.
- [ ] Remove imports/allowances used only by the fallback.
- [ ] Preserve regressions for null, dangling, deallocated, unaligned,
maximum-length, and derived-DST raw pointers.
- [ ] Keep the `KnownLayout::pointer_to_metadata` implementer contract explicit
that implementations may not dereference the pointer or require non-nullness,
alignment, liveness, or dereferenceability.
## Related work
- #3615 reports the original invalid-reference bug.
- #3629 introduces the MSRV-compatible fix and Rust-1.79 fast path.
- #67 tracks other cleanup blocked on future MSRV increases.
*Authored by an AI agent acting on Josh Liebow-Feeser's behalf.*
Contributor guide
Research direction
Start at the KnownLayout::pointer_to_metadata implementation and review #3629 to understand the compatibility path. Inspect zerocopy/Cargo.toml and the CI configuration for no_zerocopy_slice_ptr_len_1_79_0 and its boundary-toolchain entries. Done means the fallback, cfg, CI entries, and fallback-only imports are removed while the listed raw-pointer regressions and implementer contract remain covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100