diff --git a/library/core/src/mem/manually_drop.rs b/library/core/src/mem/manually_drop.rs index ca008a82ee6f0..f6b842227233d 100644 --- a/library/core/src/mem/manually_drop.rs +++ b/library/core/src/mem/manually_drop.rs @@ -1,6 +1,4 @@ -use crate::cmp::Ordering; -use crate::hash::{Hash, Hasher}; -use crate::marker::{Destruct, StructuralPartialEq}; +use crate::marker::Destruct; use crate::mem::MaybeDangling; use crate::ops::{Deref, DerefMut, DerefPure}; use crate::ptr; @@ -155,7 +153,7 @@ use crate::ptr; /// [`MaybeUninit`]: crate::mem::MaybeUninit #[stable(feature = "manually_drop", since = "1.20.0")] #[lang = "manually_drop"] -#[derive(Copy, Clone, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] #[rustc_pub_transparent] pub struct ManuallyDrop { @@ -289,37 +287,3 @@ impl const DerefMut for ManuallyDrop { #[unstable(feature = "deref_pure_trait", issue = "87121")] unsafe impl DerefPure for ManuallyDrop {} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl Eq for ManuallyDrop {} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl PartialEq for ManuallyDrop { - fn eq(&self, other: &Self) -> bool { - self.value.as_ref().eq(other.value.as_ref()) - } -} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl StructuralPartialEq for ManuallyDrop {} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl Ord for ManuallyDrop { - fn cmp(&self, other: &Self) -> Ordering { - self.value.as_ref().cmp(other.value.as_ref()) - } -} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl PartialOrd for ManuallyDrop { - fn partial_cmp(&self, other: &Self) -> Option { - self.value.as_ref().partial_cmp(other.value.as_ref()) - } -} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl Hash for ManuallyDrop { - fn hash(&self, state: &mut H) { - self.value.as_ref().hash(state); - } -} diff --git a/library/core/src/mem/maybe_dangling.rs b/library/core/src/mem/maybe_dangling.rs index 2c9c435c24085..1571c13e28a49 100644 --- a/library/core/src/mem/maybe_dangling.rs +++ b/library/core/src/mem/maybe_dangling.rs @@ -1,6 +1,5 @@ #![unstable(feature = "maybe_dangling", issue = "118166")] -use crate::marker::StructuralPartialEq; use crate::{mem, ptr}; /// Allows wrapped [references] and [boxes] to dangle. @@ -69,7 +68,7 @@ use crate::{mem, ptr}; /// [`ManuallyDrop`]: crate::mem::ManuallyDrop #[repr(transparent)] #[rustc_pub_transparent] -#[derive(Debug, Copy, Clone, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[lang = "maybe_dangling"] pub struct MaybeDangling(P); @@ -110,5 +109,3 @@ impl MaybeDangling

{ x } } - -impl StructuralPartialEq for MaybeDangling {}