Skip to content

Add initial support for unsized MaybeUninit wrapper type (#2055) #2310

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

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Feb 6, 2025

This is achieved by adding a MaybeUninit associated type to KnownLayout, whose layout is identical to Self except that it admits uninitialized bytes in all positions.

For sized types, this is bound to mem::MaybeUninit<Self>. For potentially unsized structs, we synthesize a doppelganger with the same repr, whose leading fields are wrapped in mem::MaybeUninit and whose trailing field is the MaybeUninit associated type of struct's original trailing field type. This type-level recursion bottoms out at [T], whose MaybeUninit associated type is bound to [mem::MaybeUninit<T>].

Makes progress towards #1797

SKIP_CARGO_SEMVER_CHECKS=1

gherrit-pr-id: Idfc357094e28b54a15d947141241ca2da83dcc91

@joshlf joshlf requested a review from jswrenn February 6, 2025 19:38
@joshlf
Copy link
Member Author

joshlf commented Feb 6, 2025

Backporting #2055

This is achieved by adding a `MaybeUninit` associated type to
`KnownLayout`, whose layout is identical to `Self` except that it admits
uninitialized bytes in all positions.

For sized types, this is bound to `mem::MaybeUninit<Self>`. For
potentially unsized structs, we synthesize a doppelganger with the same
`repr`, whose leading fields are wrapped in `mem::MaybeUninit` and whose
trailing field is the `MaybeUninit` associated type of struct's original
trailing field type. This type-level recursion bottoms out at `[T]`,
whose `MaybeUninit` associated type is bound to `[mem::MaybeUninit<T>]`.

Makes progress towards #1797

SKIP_CARGO_SEMVER_CHECKS=1

gherrit-pr-id: Idfc357094e28b54a15d947141241ca2da83dcc91
@joshlf joshlf added this pull request to the merge queue Feb 6, 2025
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 78.18182% with 36 lines in your changes missing coverage. Please review.

Project coverage is 89.27%. Comparing base (146fd48) to head (408f297).

Files with missing lines Patch % Lines
src/wrappers.rs 61.95% 35 Missing ⚠️
src/util/mod.rs 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2310      +/-   ##
==========================================
- Coverage   89.93%   89.27%   -0.67%     
==========================================
  Files          16       16              
  Lines        5833     5976     +143     
==========================================
+ Hits         5246     5335      +89     
- Misses        587      641      +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Merged via the queue into main with commit 3acb652 Feb 6, 2025
69 checks passed
@joshlf joshlf deleted the backport-2055 branch February 6, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants