diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index a57d83552898..4cc0a5e49d94 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -821,6 +821,7 @@ pub fn discriminant(v: &T) -> Discriminant { /// ``` #[stable(feature = "manually_drop", since = "1.20.0")] #[allow(unions_with_drop_fields)] +#[derive(Copy)] pub union ManuallyDrop{ value: T } impl ManuallyDrop { @@ -899,6 +900,19 @@ impl ::fmt::Debug for ManuallyDrop { } } +#[stable(feature = "manually_drop", since = "1.20.0")] +impl Clone for ManuallyDrop { + fn clone(&self) -> Self { + use ::ops::Deref; + ManuallyDrop::new(self.deref().clone()) + } + + fn clone_from(&mut self, source: &Self) { + use ::ops::DerefMut; + self.deref_mut().clone_from(source); + } +} + /// Tells LLVM that this point in the code is not reachable, enabling further /// optimizations. ///