Skip to content

Commit ad8e6bf

Browse files
committed
Stabilize some MaybeUninit behavior as const
1 parent 4919988 commit ad8e6bf

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ extern "rust-intrinsic" {
853853
/// This will statically either panic, or do nothing.
854854
///
855855
/// This intrinsic does not have a stable counterpart.
856-
#[rustc_const_unstable(feature = "const_assert_type", issue = "none")]
856+
#[rustc_const_stable(feature = "const_assert_type", since = "1.59.0")]
857857
pub fn assert_inhabited<T>();
858858

859859
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit

library/core/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
#![feature(const_align_of_val)]
102102
#![feature(const_alloc_layout)]
103103
#![feature(const_arguments_as_str)]
104-
#![feature(const_assert_type)]
105104
#![feature(const_bigint_helper_methods)]
106105
#![feature(const_caller_location)]
107106
#![feature(const_cell_into_inner)]
@@ -117,7 +116,7 @@
117116
#![feature(const_intrinsic_copy)]
118117
#![feature(const_intrinsic_forget)]
119118
#![feature(const_likely)]
120-
#![feature(const_maybe_uninit_as_ptr)]
119+
#![feature(const_maybe_uninit_as_mut_ptr)]
121120
#![feature(const_maybe_uninit_assume_init)]
122121
#![feature(const_num_from_num)]
123122
#![feature(const_ops)]

library/core/src/mem/maybe_uninit.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl<T> MaybeUninit<T> {
528528
/// (Notice that the rules around references to uninitialized data are not finalized yet, but
529529
/// until they are, it is advisable to avoid them.)
530530
#[stable(feature = "maybe_uninit", since = "1.36.0")]
531-
#[rustc_const_unstable(feature = "const_maybe_uninit_as_ptr", issue = "75251")]
531+
#[rustc_const_stable(feature = "const_maybe_uninit_as_ptr", since = "1.59.0")]
532532
#[inline(always)]
533533
pub const fn as_ptr(&self) -> *const T {
534534
// `MaybeUninit` and `ManuallyDrop` are both `repr(transparent)` so we can cast the pointer.
@@ -567,7 +567,7 @@ impl<T> MaybeUninit<T> {
567567
/// (Notice that the rules around references to uninitialized data are not finalized yet, but
568568
/// until they are, it is advisable to avoid them.)
569569
#[stable(feature = "maybe_uninit", since = "1.36.0")]
570-
#[rustc_const_unstable(feature = "const_maybe_uninit_as_ptr", issue = "75251")]
570+
#[rustc_const_unstable(feature = "const_maybe_uninit_as_mut_ptr", issue = "75251")]
571571
#[inline(always)]
572572
pub const fn as_mut_ptr(&mut self) -> *mut T {
573573
// `MaybeUninit` and `ManuallyDrop` are both `repr(transparent)` so we can cast the pointer.
@@ -620,7 +620,7 @@ impl<T> MaybeUninit<T> {
620620
/// // `x` had not been initialized yet, so this last line caused undefined behavior. ⚠️
621621
/// ```
622622
#[stable(feature = "maybe_uninit", since = "1.36.0")]
623-
#[rustc_const_unstable(feature = "const_maybe_uninit_assume_init", issue = "none")]
623+
#[rustc_const_stable(feature = "const_maybe_uninit_assume_init", since = "1.59.0")]
624624
#[inline(always)]
625625
#[rustc_diagnostic_item = "assume_init"]
626626
#[track_caller]
@@ -788,7 +788,8 @@ impl<T> MaybeUninit<T> {
788788
/// }
789789
/// ```
790790
#[stable(feature = "maybe_uninit_ref", since = "1.55.0")]
791-
#[rustc_const_unstable(feature = "const_maybe_uninit_assume_init", issue = "none")]
791+
#[rustc_const_stable(feature = "const_maybe_uninit_assume_init", since = "1.59.0")]
792+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_raw_ptr_deref))]
792793
#[inline(always)]
793794
pub const unsafe fn assume_init_ref(&self) -> &T {
794795
// SAFETY: the caller must guarantee that `self` is initialized.
@@ -968,7 +969,7 @@ impl<T> MaybeUninit<T> {
968969
///
969970
/// [`assume_init_ref`]: MaybeUninit::assume_init_ref
970971
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
971-
#[rustc_const_unstable(feature = "const_maybe_uninit_assume_init", issue = "none")]
972+
#[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")]
972973
#[inline(always)]
973974
pub const unsafe fn slice_assume_init_ref(slice: &[Self]) -> &[T] {
974975
// SAFETY: casting slice to a `*const [T]` is safe since the caller guarantees that

0 commit comments

Comments
 (0)