Rollup merge of #132455 - RalfJung:const_alloc_layout, r=dtolnay
make const_alloc_layout feature gate only about functions that are already stable The const_alloc_layout feature gate has two kinds of functions: those that are stable, but not yet const-stable, and those that are fully unstable. I think we should split that up. So this PR makes const_alloc_layout just about functions that are already stable but waiting for const-stability; all the other functions now have their constness guarded by the gate that also guards their regular stability. Cc https://github.com/rust-lang/rust/issues/67521
This commit is contained in:
commit
d5366090f9
1 changed files with 5 additions and 6 deletions
|
@ -216,7 +216,7 @@ impl Layout {
|
||||||
/// [trait object]: ../../book/ch17-02-trait-objects.html
|
/// [trait object]: ../../book/ch17-02-trait-objects.html
|
||||||
/// [extern type]: ../../unstable-book/language-features/extern-types.html
|
/// [extern type]: ../../unstable-book/language-features/extern-types.html
|
||||||
#[unstable(feature = "layout_for_ptr", issue = "69835")]
|
#[unstable(feature = "layout_for_ptr", issue = "69835")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
#[rustc_const_unstable(feature = "layout_for_ptr", issue = "69835")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const unsafe fn for_value_raw<T: ?Sized>(t: *const T) -> Self {
|
pub const unsafe fn for_value_raw<T: ?Sized>(t: *const T) -> Self {
|
||||||
// SAFETY: we pass along the prerequisites of these functions to the caller
|
// SAFETY: we pass along the prerequisites of these functions to the caller
|
||||||
|
@ -232,7 +232,6 @@ impl Layout {
|
||||||
/// sentinel value. Types that lazily allocate must track initialization by
|
/// sentinel value. Types that lazily allocate must track initialization by
|
||||||
/// some other means.
|
/// some other means.
|
||||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||||
#[rustc_const_unstable(feature = "alloc_layout_extra", issue = "55724")]
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn dangling(&self) -> NonNull<u8> {
|
pub const fn dangling(&self) -> NonNull<u8> {
|
||||||
|
@ -256,6 +255,7 @@ impl Layout {
|
||||||
/// `align` violates the conditions listed in [`Layout::from_size_align`].
|
/// `align` violates the conditions listed in [`Layout::from_size_align`].
|
||||||
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||||
|
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn align_to(&self, align: usize) -> Result<Self, LayoutError> {
|
pub const fn align_to(&self, align: usize) -> Result<Self, LayoutError> {
|
||||||
if let Some(align) = Alignment::new(align) {
|
if let Some(align) = Alignment::new(align) {
|
||||||
|
@ -282,7 +282,6 @@ impl Layout {
|
||||||
/// address for the whole allocated block of memory. One way to
|
/// address for the whole allocated block of memory. One way to
|
||||||
/// satisfy this constraint is to ensure `align <= self.align()`.
|
/// satisfy this constraint is to ensure `align <= self.align()`.
|
||||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
|
||||||
#[must_use = "this returns the padding needed, \
|
#[must_use = "this returns the padding needed, \
|
||||||
without modifying the `Layout`"]
|
without modifying the `Layout`"]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -332,6 +331,7 @@ impl Layout {
|
||||||
/// to the layout's current size.
|
/// to the layout's current size.
|
||||||
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||||
|
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
|
||||||
#[must_use = "this returns a new `Layout`, \
|
#[must_use = "this returns a new `Layout`, \
|
||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -374,7 +374,6 @@ impl Layout {
|
||||||
/// assert_eq!(repeated, (Layout::from_size_align(24, 4).unwrap(), 8));
|
/// assert_eq!(repeated, (Layout::from_size_align(24, 4).unwrap(), 8));
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
|
pub const fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
|
||||||
let padded = self.pad_to_align();
|
let padded = self.pad_to_align();
|
||||||
|
@ -432,6 +431,7 @@ impl Layout {
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||||
|
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> {
|
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> {
|
||||||
let new_align = Alignment::max(self.align, next.align);
|
let new_align = Alignment::max(self.align, next.align);
|
||||||
|
@ -463,7 +463,6 @@ impl Layout {
|
||||||
///
|
///
|
||||||
/// On arithmetic overflow, returns `LayoutError`.
|
/// On arithmetic overflow, returns `LayoutError`.
|
||||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError> {
|
pub const fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError> {
|
||||||
if let Some(size) = self.size.checked_mul(n) {
|
if let Some(size) = self.size.checked_mul(n) {
|
||||||
|
@ -481,7 +480,6 @@ impl Layout {
|
||||||
///
|
///
|
||||||
/// On arithmetic overflow, returns `LayoutError`.
|
/// On arithmetic overflow, returns `LayoutError`.
|
||||||
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn extend_packed(&self, next: Self) -> Result<Self, LayoutError> {
|
pub const fn extend_packed(&self, next: Self) -> Result<Self, LayoutError> {
|
||||||
// SAFETY: each `size` is at most `isize::MAX == usize::MAX/2`, so the
|
// SAFETY: each `size` is at most `isize::MAX == usize::MAX/2`, so the
|
||||||
|
@ -497,6 +495,7 @@ impl Layout {
|
||||||
/// `isize::MAX`, returns `LayoutError`.
|
/// `isize::MAX`, returns `LayoutError`.
|
||||||
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
|
||||||
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
|
||||||
|
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn array<T>(n: usize) -> Result<Self, LayoutError> {
|
pub const fn array<T>(n: usize) -> Result<Self, LayoutError> {
|
||||||
// Reduce the amount of code we need to monomorphize per `T`.
|
// Reduce the amount of code we need to monomorphize per `T`.
|
||||||
|
|
Loading…
Add table
Reference in a new issue