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).
So which is it? Is
ManuallyDropallowed to contain uninitialised data, or isManuallyDrop::dropalways insta-UB to call? What counts as "using" aManuallyDroptype after dropping it?edit:
On a related note, the documentation for
ManuallyDrop::dropshould probably guarantee that the value is dropped in-place, without moving (and is thus OK to use with pinned data).