Skip to content

Commit 7510b0c

Browse files
committed
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
2 parents 1483156 + 5b2076f commit 7510b0c

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

library/core/src/mem/manually_drop.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::ptr;
4444
/// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
4545
#[stable(feature = "manually_drop", since = "1.20.0")]
4646
#[lang = "manually_drop"]
47-
#[derive(Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
47+
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4848
#[repr(transparent)]
4949
pub struct ManuallyDrop<T: ?Sized> {
5050
value: T,
@@ -160,16 +160,3 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
160160
&mut self.value
161161
}
162162
}
163-
164-
#[stable(feature = "manually_drop", since = "1.20.0")]
165-
impl<T: Clone> Clone for ManuallyDrop<T> {
166-
#[inline]
167-
fn clone(&self) -> ManuallyDrop<T> {
168-
ManuallyDrop { value: self.value.clone() }
169-
}
170-
171-
#[inline]
172-
fn clone_from(&mut self, other: &Self) {
173-
self.value.clone_from(&other.value)
174-
}
175-
}

0 commit comments

Comments
 (0)