Skip to content

Commit 02ff5c3

Browse files
committed
make const_alloc_layout feature gate only about functions that are already stable
the rest has their constness guarded by their usual feature gate
1 parent a8e1186 commit 02ff5c3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

library/core/src/alloc/layout.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl Layout {
216216
/// [trait object]: ../../book/ch17-02-trait-objects.html
217217
/// [extern type]: ../../unstable-book/language-features/extern-types.html
218218
#[unstable(feature = "layout_for_ptr", issue = "69835")]
219-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
219+
#[rustc_const_unstable(feature = "layout_for_ptr", issue = "69835")]
220220
#[must_use]
221221
pub const unsafe fn for_value_raw<T: ?Sized>(t: *const T) -> Self {
222222
// SAFETY: we pass along the prerequisites of these functions to the caller
@@ -232,7 +232,6 @@ impl Layout {
232232
/// sentinel value. Types that lazily allocate must track initialization by
233233
/// some other means.
234234
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
235-
#[rustc_const_unstable(feature = "alloc_layout_extra", issue = "55724")]
236235
#[must_use]
237236
#[inline]
238237
pub const fn dangling(&self) -> NonNull<u8> {
@@ -282,7 +281,6 @@ impl Layout {
282281
/// address for the whole allocated block of memory. One way to
283282
/// satisfy this constraint is to ensure `align <= self.align()`.
284283
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
285-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
286284
#[must_use = "this returns the padding needed, \
287285
without modifying the `Layout`"]
288286
#[inline]
@@ -332,6 +330,7 @@ impl Layout {
332330
/// to the layout's current size.
333331
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
334332
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
333+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
335334
#[must_use = "this returns a new `Layout`, \
336335
without modifying the original"]
337336
#[inline]
@@ -374,7 +373,6 @@ impl Layout {
374373
/// assert_eq!(repeated, (Layout::from_size_align(24, 4).unwrap(), 8));
375374
/// ```
376375
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
377-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
378376
#[inline]
379377
pub const fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
380378
let padded = self.pad_to_align();
@@ -432,6 +430,7 @@ impl Layout {
432430
/// ```
433431
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
434432
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
433+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
435434
#[inline]
436435
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> {
437436
let new_align = Alignment::max(self.align, next.align);
@@ -463,7 +462,6 @@ impl Layout {
463462
///
464463
/// On arithmetic overflow, returns `LayoutError`.
465464
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
466-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
467465
#[inline]
468466
pub const fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError> {
469467
if let Some(size) = self.size.checked_mul(n) {
@@ -481,7 +479,6 @@ impl Layout {
481479
///
482480
/// On arithmetic overflow, returns `LayoutError`.
483481
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
484-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
485482
#[inline]
486483
pub const fn extend_packed(&self, next: Self) -> Result<Self, LayoutError> {
487484
// SAFETY: each `size` is at most `isize::MAX == usize::MAX/2`, so the
@@ -497,6 +494,7 @@ impl Layout {
497494
/// `isize::MAX`, returns `LayoutError`.
498495
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
499496
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
497+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
500498
#[inline]
501499
pub const fn array<T>(n: usize) -> Result<Self, LayoutError> {
502500
// Reduce the amount of code we need to monomorphize per `T`.

0 commit comments

Comments
 (0)