-
Notifications
You must be signed in to change notification settings - Fork 105
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
[wip] UnalignUnsized #1828
base: maybe-uninit
Are you sure you want to change the base?
[wip] UnalignUnsized #1828
Conversation
a081f40
to
41b007b
Compare
e7dc008
to
7d7b050
Compare
src/lib.rs
Outdated
@@ -893,6 +930,57 @@ unsafe impl<T> KnownLayout for [T] { | |||
// struct `Foo(i32, [u8])` or `(u64, Foo)`. | |||
slc.len() | |||
} | |||
|
|||
#[cfg(feature = "alloc")] | |||
unsafe fn drop(slf: &mut UnalignUnsized<Self>) { |
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.
Does this play nicely with Pin
'd types?
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.
Yes, Pin bars you from moving the referent before running its destructor. It doesn't place any restrictions on what you do in the destructor.
6860aa4
to
a9458e8
Compare
271b768
to
96b54d1
Compare
7d7b050
to
c1205be
Compare
96b54d1
to
9844c1f
Compare
9751180
to
ca928f5
Compare
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
ca928f5
to
7da393c
Compare
c1205be
to
e8cc8eb
Compare
235989d
to
bb140d0
Compare
todo!()
s remain. I suspect some of this would be easier, too, if we hadPtr
integration withUnalignUnsized
.