Update with derive_const
This commit is contained in:
parent
414e84a2f7
commit
6f2dcac78b
library/core/src
@ -326,7 +326,10 @@ impl Layout {
|
|||||||
let alloc_size = padded_size.checked_mul(n).ok_or(LayoutError)?;
|
let alloc_size = padded_size.checked_mul(n).ok_or(LayoutError)?;
|
||||||
|
|
||||||
// The safe constructor is called here to enforce the isize size limit.
|
// The safe constructor is called here to enforce the isize size limit.
|
||||||
Layout::from_size_alignment(alloc_size, self.align).map(|layout| (layout, padded_size))
|
match Layout::from_size_alignment(alloc_size, self.align) {
|
||||||
|
Ok(layout) => Ok((layout, padded_size)),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a layout describing the record for `self` followed by
|
/// Creates a layout describing the record for `self` followed by
|
||||||
|
@ -10,6 +10,8 @@ use crate::{cmp, fmt, hash, mem, num};
|
|||||||
/// are likely not to be supported by actual allocators and linkers.
|
/// are likely not to be supported by actual allocators and linkers.
|
||||||
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
||||||
#[derive(Copy, Clone, Eq)]
|
#[derive(Copy, Clone, Eq)]
|
||||||
|
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||||
|
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Alignment(AlignmentEnum);
|
pub struct Alignment(AlignmentEnum);
|
||||||
|
|
||||||
@ -167,15 +169,6 @@ impl From<Alignment> for usize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
|
||||||
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
|
||||||
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")]
|
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||||
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
||||||
impl const cmp::Ord for Alignment {
|
impl const cmp::Ord for Alignment {
|
||||||
@ -209,7 +202,9 @@ type AlignmentEnum = AlignmentEnum32;
|
|||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
type AlignmentEnum = AlignmentEnum64;
|
type AlignmentEnum = AlignmentEnum64;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq)]
|
||||||
|
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||||
|
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
enum AlignmentEnum16 {
|
enum AlignmentEnum16 {
|
||||||
_Align1Shl0 = 1 << 0,
|
_Align1Shl0 = 1 << 0,
|
||||||
@ -230,7 +225,9 @@ enum AlignmentEnum16 {
|
|||||||
_Align1Shl15 = 1 << 15,
|
_Align1Shl15 = 1 << 15,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq)]
|
||||||
|
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||||
|
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
enum AlignmentEnum32 {
|
enum AlignmentEnum32 {
|
||||||
_Align1Shl0 = 1 << 0,
|
_Align1Shl0 = 1 << 0,
|
||||||
@ -267,7 +264,9 @@ enum AlignmentEnum32 {
|
|||||||
_Align1Shl31 = 1 << 31,
|
_Align1Shl31 = 1 << 31,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq)]
|
||||||
|
#[cfg_attr(bootstrap, derive(PartialEq))]
|
||||||
|
#[cfg_attr(not(bootstrap), derive_const(PartialEq))]
|
||||||
#[repr(u64)]
|
#[repr(u64)]
|
||||||
enum AlignmentEnum64 {
|
enum AlignmentEnum64 {
|
||||||
_Align1Shl0 = 1 << 0,
|
_Align1Shl0 = 1 << 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user