-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
A-dropTopic: related to droppingTopic: related to droppingC-supportCategory: Supporting a user to solve a concrete problemCategory: Supporting a user to solve a concrete problem
Description
In particular, initializing a ManuallyDrop<&mut T> with mem::zeroed is undefined behavior. If you need to handle uninitialized data, use MaybeUninit instead.
pub unsafe fn drop(slot: &mut ManuallyDrop<T>)
This function runs the destructor of the contained value and thus the wrapped value now represents uninitialized data.
So which is it? Is ManuallyDrop
allowed to contain uninitialised data, or is ManuallyDrop::drop
always insta-UB to call? What counts as "using" a ManuallyDrop
type after dropping it?
edit:
On a related note, the documentation for ManuallyDrop::drop
should probably guarantee that the value is dropped in-place, without moving (and is thus OK to use with pinned data).
Metadata
Metadata
Assignees
Labels
A-dropTopic: related to droppingTopic: related to droppingC-supportCategory: Supporting a user to solve a concrete problemCategory: Supporting a user to solve a concrete problem