about summary refs log tree commit diff
path: root/library/core/src/ptr/alignment.rs
diff options
context:
space:
mode:
authorRune Tynan <runetynan@gmail.com>2022-09-23 15:14:34 -0400
committerRune Tynan <runetynan@gmail.com>2022-11-20 15:01:21 -0500
commit9f4b4e46a3ba5602916e96f8a4186eaf63d91682 (patch)
tree7f00b0955b368fcfd63df2e397943cbe4a7d3394 /library/core/src/ptr/alignment.rs
parent911cbf8e46f0f3b044c87fc5cbca922878db757b (diff)
downloadrust-9f4b4e46a3ba5602916e96f8a4186eaf63d91682.tar.gz
rust-9f4b4e46a3ba5602916e96f8a4186eaf63d91682.zip
constify remaining layout methods
Remove bad impl for Eq

Update Cargo.lock and fix last ValidAlign
Diffstat (limited to 'library/core/src/ptr/alignment.rs')
-rw-r--r--library/core/src/ptr/alignment.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs
index 1390e09dd96..61eb23c7bca 100644
--- a/library/core/src/ptr/alignment.rs
+++ b/library/core/src/ptr/alignment.rs
@@ -9,7 +9,7 @@ use crate::{cmp, fmt, hash, mem, num};
 /// Note that particularly large alignments, while representable in this type,
 /// are likely not to be supported by actual allocators and linkers.
 #[unstable(feature = "ptr_alignment_type", issue = "102070")]
-#[derive(Copy, Clone, Eq, PartialEq)]
+#[derive(Copy, Clone, Eq)]
 #[repr(transparent)]
 pub struct Alignment(AlignmentEnum);
 
@@ -167,16 +167,25 @@ impl From<Alignment> for usize {
     }
 }
 
-#[unstable(feature = "ptr_alignment_type", issue = "102070")]
-impl cmp::Ord for Alignment {
+#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
+impl const cmp::PartialEq for Alignment {
+    #[inline]
+    fn eq(&self, other: &Self) -> bool {
+        self.as_nonzero().get() == other.as_nonzero().get()
+    }
+}
+
+#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
+impl const cmp::Ord for Alignment {
     #[inline]
     fn cmp(&self, other: &Self) -> cmp::Ordering {
-        self.as_nonzero().cmp(&other.as_nonzero())
+        self.as_nonzero().get().cmp(&other.as_nonzero().get())
     }
 }
 
+#[rustc_const_unstable(feature = "const_alloc_layout", issue = "87864")]
 #[unstable(feature = "ptr_alignment_type", issue = "102070")]
-impl cmp::PartialOrd for Alignment {
+impl const cmp::PartialOrd for Alignment {
     #[inline]
     fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
         Some(self.cmp(other))