about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-14 10:24:48 +0000
committerbors <bors@rust-lang.org>2021-06-14 10:24:48 +0000
commit7510b0ca45d1204f8f0e9dc1bb2dc7d95b279c9a (patch)
treeb890814ecb2c19a3379ba568f075d639691288b1
parent14831568d506b5ee7be3e7d5a2f029ce9048b609 (diff)
parent5b2076ff01c75d4b7e09dac5b5630ecb16d66255 (diff)
downloadrust-7510b0ca45d1204f8f0e9dc1bb2dc7d95b279c9a.tar.gz
rust-7510b0ca45d1204f8f0e9dc1bb2dc7d95b279c9a.zip
Auto merge of #85758 - petertodd:2021-revert-manuallydrop-clone-from, r=m-ou-se
Revert #85176 addition of `clone_from` for `ManuallyDrop`

Forwarding `clone_from` to the inner value changes the observable behavior, as previously the inner value would *not* be dropped by the default implementation.

Frankly, this is a super-niche case, so #85176 is welcome to argue the behavior should be otherwise! But if we overrride it, IMO documenting the behavior would be good.

Example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c5d0856686fa850c1d7ee16891014efb
-rw-r--r--library/core/src/mem/manually_drop.rs15
1 files changed, 1 insertions, 14 deletions
diff --git a/library/core/src/mem/manually_drop.rs b/library/core/src/mem/manually_drop.rs
index 5b99f6954e6..d86939454be 100644
--- a/library/core/src/mem/manually_drop.rs
+++ b/library/core/src/mem/manually_drop.rs
@@ -44,7 +44,7 @@ use crate::ptr;
 /// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
 #[stable(feature = "manually_drop", since = "1.20.0")]
 #[lang = "manually_drop"]
-#[derive(Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[repr(transparent)]
 pub struct ManuallyDrop<T: ?Sized> {
     value: T,
@@ -160,16 +160,3 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
         &mut self.value
     }
 }
-
-#[stable(feature = "manually_drop", since = "1.20.0")]
-impl<T: Clone> Clone for ManuallyDrop<T> {
-    #[inline]
-    fn clone(&self) -> ManuallyDrop<T> {
-        ManuallyDrop { value: self.value.clone() }
-    }
-
-    #[inline]
-    fn clone_from(&mut self, other: &Self) {
-        self.value.clone_from(&other.value)
-    }
-}