Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9e0a3a7

Browse files
authoredNov 1, 2024
Rollup merge of rust-lang#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 rust-lang#67521
2 parents b80eb4b + c9e77e8 commit 9e0a3a7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
 

‎library/core/src/alloc/layout.rs

+5-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> {
@@ -256,6 +255,7 @@ impl Layout {
256255
/// `align` violates the conditions listed in [`Layout::from_size_align`].
257256
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
258257
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
258+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
259259
#[inline]
260260
pub const fn align_to(&self, align: usize) -> Result<Self, LayoutError> {
261261
if let Some(align) = Alignment::new(align) {
@@ -282,7 +282,6 @@ impl Layout {
282282
/// address for the whole allocated block of memory. One way to
283283
/// satisfy this constraint is to ensure `align <= self.align()`.
284284
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
285-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
286285
#[must_use = "this returns the padding needed, \
287286
without modifying the `Layout`"]
288287
#[inline]
@@ -332,6 +331,7 @@ impl Layout {
332331
/// to the layout's current size.
333332
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
334333
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
334+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
335335
#[must_use = "this returns a new `Layout`, \
336336
without modifying the original"]
337337
#[inline]
@@ -374,7 +374,6 @@ impl Layout {
374374
/// assert_eq!(repeated, (Layout::from_size_align(24, 4).unwrap(), 8));
375375
/// ```
376376
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
377-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
378377
#[inline]
379378
pub const fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
380379
let padded = self.pad_to_align();
@@ -432,6 +431,7 @@ impl Layout {
432431
/// ```
433432
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
434433
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
434+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
435435
#[inline]
436436
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError> {
437437
let new_align = Alignment::max(self.align, next.align);
@@ -463,7 +463,6 @@ impl Layout {
463463
///
464464
/// On arithmetic overflow, returns `LayoutError`.
465465
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
466-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
467466
#[inline]
468467
pub const fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError> {
469468
if let Some(size) = self.size.checked_mul(n) {
@@ -481,7 +480,6 @@ impl Layout {
481480
///
482481
/// On arithmetic overflow, returns `LayoutError`.
483482
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
484-
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
485483
#[inline]
486484
pub const fn extend_packed(&self, next: Self) -> Result<Self, LayoutError> {
487485
// SAFETY: each `size` is at most `isize::MAX == usize::MAX/2`, so the
@@ -497,6 +495,7 @@ impl Layout {
497495
/// `isize::MAX`, returns `LayoutError`.
498496
#[stable(feature = "alloc_layout_manipulation", since = "1.44.0")]
499497
#[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
498+
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
500499
#[inline]
501500
pub const fn array<T>(n: usize) -> Result<Self, LayoutError> {
502501
// Reduce the amount of code we need to monomorphize per `T`.

0 commit comments

Comments
 (0)
Please sign in to comment.