diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 8f6798e0f6e..296f15d8303 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -1106,12 +1106,22 @@ fn deref_mut(&mut self) -> &mut T { // FIXME before stabilizing, explain how to initialize a struct field-by-field. #[allow(missing_debug_implementations)] #[unstable(feature = "maybe_uninit", issue = "53491")] +#[derive(Copy)] // NOTE after stabilizing `MaybeUninit` proceed to deprecate `mem::uninitialized` pub union MaybeUninit { uninit: (), value: ManuallyDrop, } +#[unstable(feature = "maybe_uninit", issue = "53491")] +impl Clone for MaybeUninit { + #[inline(always)] + fn clone(&self) -> Self { + // Not calling T::clone(), we cannot know if we are initialized enough for that. + *self + } +} + impl MaybeUninit { /// Create a new `MaybeUninit` initialized with the given value. ///