Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions library/core/src/mem/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ 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, PartialEq, Eq)]
#[derive(Copy)]
#[derive_const(Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct Alignment {
// This field is never used directly (nor is the enum),
Expand Down Expand Up @@ -303,15 +304,17 @@ impl const From<Alignment> for usize {
}

#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl cmp::Ord for Alignment {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const cmp::Ord for Alignment {
#[inline]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.as_nonzero_usize().cmp(&other.as_nonzero_usize())
}
}

#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl cmp::PartialOrd for Alignment {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const cmp::PartialOrd for Alignment {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
Some(self.cmp(other))
Expand All @@ -336,7 +339,8 @@ impl const Default for Alignment {
}

#[cfg(target_pointer_width = "16")]
#[derive(Copy, Clone, PartialEq, Eq)]
#[derive(Copy)]
#[derive_const(Clone, PartialEq, Eq)]
#[repr(usize)]
enum AlignmentEnum {
_Align1Shl0 = 1 << 0,
Expand All @@ -358,7 +362,8 @@ enum AlignmentEnum {
}

#[cfg(target_pointer_width = "32")]
#[derive(Copy, Clone, PartialEq, Eq)]
#[derive(Copy)]
#[derive_const(Clone, PartialEq, Eq)]
#[repr(usize)]
enum AlignmentEnum {
_Align1Shl0 = 1 << 0,
Expand Down Expand Up @@ -396,7 +401,8 @@ enum AlignmentEnum {
}

#[cfg(target_pointer_width = "64")]
#[derive(Copy, Clone, PartialEq, Eq)]
#[derive(Copy)]
#[derive_const(Clone, PartialEq, Eq)]
#[repr(usize)]
enum AlignmentEnum {
_Align1Shl0 = 1 << 0,
Expand Down
Loading