@@ -350,13 +350,13 @@ impl<T> MaybeUninit<T> {
350
350
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
351
351
/// let data = read(&mut buf);
352
352
/// ```
353
- #[ unstable( feature = "maybe_uninit_uninit_array" , issue = "none " ) ]
354
- #[ rustc_const_unstable( feature = "maybe_uninit_uninit_array " , issue = "none " ) ]
353
+ #[ unstable( feature = "maybe_uninit_uninit_array" , issue = "96097 " ) ]
354
+ #[ rustc_const_unstable( feature = "const_maybe_uninit_uninit_array " , issue = "96097 " ) ]
355
355
#[ must_use]
356
356
#[ inline( always) ]
357
- pub const fn uninit_array < const LEN : usize > ( ) -> [ Self ; LEN ] {
357
+ pub const fn uninit_array < const N : usize > ( ) -> [ Self ; N ] {
358
358
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
359
- unsafe { MaybeUninit :: < [ MaybeUninit < T > ; LEN ] > :: uninit ( ) . assume_init ( ) }
359
+ unsafe { MaybeUninit :: < [ MaybeUninit < T > ; N ] > :: uninit ( ) . assume_init ( ) }
360
360
}
361
361
362
362
/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
@@ -942,19 +942,24 @@ impl<T> MaybeUninit<T> {
942
942
///
943
943
/// assert_eq!(array, [0, 1, 2]);
944
944
/// ```
945
- #[ unstable( feature = "maybe_uninit_array_assume_init" , issue = "80908" ) ]
945
+ #[ unstable( feature = "maybe_uninit_array_assume_init" , issue = "96097" ) ]
946
+ #[ rustc_const_unstable( feature = "const_maybe_uninit_array_assume_init" , issue = "96097" ) ]
946
947
#[ inline( always) ]
947
948
#[ track_caller]
948
- pub unsafe fn array_assume_init < const N : usize > ( array : [ Self ; N ] ) -> [ T ; N ] {
949
+ pub const unsafe fn array_assume_init < const N : usize > ( array : [ Self ; N ] ) -> [ T ; N ] {
949
950
// SAFETY:
950
951
// * The caller guarantees that all elements of the array are initialized
951
952
// * `MaybeUninit<T>` and T are guaranteed to have the same layout
952
953
// * `MaybeUninit` does not drop, so there are no double-frees
953
954
// And thus the conversion is safe
954
- unsafe {
955
+ let ret = unsafe {
955
956
intrinsics:: assert_inhabited :: < [ T ; N ] > ( ) ;
956
957
( & array as * const _ as * const [ T ; N ] ) . read ( )
957
- }
958
+ } ;
959
+
960
+ // FIXME: required to avoid `~const Destruct` bound
961
+ super :: forget ( array) ;
962
+ ret
958
963
}
959
964
960
965
/// Assuming all the elements are initialized, get a slice to them.
0 commit comments