Skip to content

Commit 1ef5dbe

Browse files
committed
Resolved some of the comments
* Undo fn -> const fn for some fns. * Split feature gate. * Made all three intrinsics const
1 parent 91772c3 commit 1ef5dbe

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

library/core/src/intrinsics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -815,19 +815,21 @@ extern "rust-intrinsic" {
815815
/// This will statically either panic, or do nothing.
816816
///
817817
/// This intrinsic does not have a stable counterpart.
818-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
818+
#[rustc_const_unstable(feature = "const_assert_type", issue = "none")]
819819
pub fn assert_inhabited<T>();
820820

821821
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit
822822
/// zero-initialization: This will statically either panic, or do nothing.
823823
///
824824
/// This intrinsic does not have a stable counterpart.
825+
#[rustc_const_unstable(feature = "const_assert_type", issue = "none")]
825826
pub fn assert_zero_valid<T>();
826827

827828
/// A guard for unsafe functions that cannot ever be executed if `T` has invalid
828829
/// bit patterns: This will statically either panic, or do nothing.
829830
///
830831
/// This intrinsic does not have a stable counterpart.
832+
#[rustc_const_unstable(feature = "const_assert_type", issue = "none")]
831833
pub fn assert_uninit_valid<T>();
832834

833835
/// Gets a reference to a static `Location` indicating where it was called.

library/core/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#![feature(asm)]
7070
#![feature(cfg_target_has_atomic)]
7171
#![feature(const_alloc_layout)]
72+
#![feature(const_assert_type)]
7273
#![feature(const_discriminant)]
7374
#![feature(const_cell_into_inner)]
7475
#![feature(const_checked_int_methods)]
@@ -101,7 +102,7 @@
101102
#![feature(const_type_name)]
102103
#![feature(const_likely)]
103104
#![feature(const_unreachable_unchecked)]
104-
#![feature(const_maybe_assume_init)]
105+
#![feature(const_maybe_uninit_assume_init)]
105106
#![feature(custom_inner_attributes)]
106107
#![feature(decl_macro)]
107108
#![feature(doc_cfg)]

library/core/src/mem/maybe_uninit.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ impl<T> MaybeUninit<T> {
314314
/// let data = read(&mut buf);
315315
/// ```
316316
#[unstable(feature = "maybe_uninit_uninit_array", issue = "none")]
317-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
318-
#[rustc_allow_const_fn_unstable(const_maybe_assume_init)]
317+
#[rustc_const_unstable(feature = "maybe_uninit_uninit_array", issue = "none")]
319318
#[inline(always)]
320319
pub const fn uninit_array<const LEN: usize>() -> [Self; LEN] {
321320
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
@@ -505,7 +504,7 @@ impl<T> MaybeUninit<T> {
505504
/// // `x` had not been initialized yet, so this last line caused undefined behavior. ⚠️
506505
/// ```
507506
#[stable(feature = "maybe_uninit", since = "1.36.0")]
508-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
507+
#[rustc_const_unstable(feature = "const_maybe_uninit_assume_init", issue = "none")]
509508
#[inline(always)]
510509
#[rustc_diagnostic_item = "assume_init"]
511510
pub const unsafe fn assume_init(self) -> T {
@@ -813,7 +812,7 @@ impl<T> MaybeUninit<T> {
813812
///
814813
/// [`assume_init_ref`]: MaybeUninit::assume_init_ref
815814
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
816-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
815+
#[rustc_const_unstable(feature = "const_maybe_uninit_assume_init", issue = "none")]
817816
#[inline(always)]
818817
pub const unsafe fn slice_assume_init_ref(slice: &[Self]) -> &[T] {
819818
// SAFETY: casting slice to a `*const [T]` is safe since the caller guarantees that
@@ -835,7 +834,7 @@ impl<T> MaybeUninit<T> {
835834
///
836835
/// [`assume_init_mut`]: MaybeUninit::assume_init_mut
837836
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
838-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
837+
#[rustc_const_unstable(feature = "const_maybe_uninit_assume_init", issue = "none")]
839838
#[inline(always)]
840839
pub const unsafe fn slice_assume_init_mut(slice: &mut [Self]) -> &mut [T] {
841840
// SAFETY: similar to safety notes for `slice_get_ref`, but we have a
@@ -845,17 +844,15 @@ impl<T> MaybeUninit<T> {
845844

846845
/// Gets a pointer to the first element of the array.
847846
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
848-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
849847
#[inline(always)]
850-
pub const fn slice_as_ptr(this: &[MaybeUninit<T>]) -> *const T {
848+
pub fn slice_as_ptr(this: &[MaybeUninit<T>]) -> *const T {
851849
this.as_ptr() as *const T
852850
}
853851

854852
/// Gets a mutable pointer to the first element of the array.
855853
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
856-
#[rustc_const_unstable(feature = "const_maybe_assume_init", issue = "none")]
857854
#[inline(always)]
858-
pub const fn slice_as_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
855+
pub fn slice_as_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
859856
this.as_mut_ptr() as *mut T
860857
}
861858
}

0 commit comments

Comments
 (0)