diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index da84763836e..2fd8180f8b2 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -217,6 +217,7 @@ #![feature(unboxed_closures)] #![feature(unsized_fn_params)] #![feature(asm_const)] +#![feature(const_transmute_copy)] // // Target features: #![feature(arm_target_feature)] diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 2ae96367628..efad9a9391b 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -1297,7 +1297,8 @@ pub fn slice_as_bytes_mut(this: &mut [MaybeUninit]) -> &mut [MaybeUninit] /// let data: [MaybeUninit; 1000] = MaybeUninit::uninit().transpose(); /// ``` #[unstable(feature = "maybe_uninit_uninit_array_transpose", issue = "96097")] - pub fn transpose(self) -> [MaybeUninit; N] { + #[inline] + pub const fn transpose(self) -> [MaybeUninit; N] { // SAFETY: T and MaybeUninit have the same layout unsafe { super::transmute_copy(&ManuallyDrop::new(self)) } } @@ -1316,7 +1317,8 @@ pub fn slice_as_bytes_mut(this: &mut [MaybeUninit]) -> &mut [MaybeUninit] /// let data: MaybeUninit<[u8; 1000]> = data.transpose(); /// ``` #[unstable(feature = "maybe_uninit_uninit_array_transpose", issue = "96097")] - pub fn transpose(self) -> MaybeUninit<[T; N]> { + #[inline] + pub const fn transpose(self) -> MaybeUninit<[T; N]> { // SAFETY: T and MaybeUninit have the same layout unsafe { super::transmute_copy(&ManuallyDrop::new(self)) } }