File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -815,6 +815,7 @@ extern "rust-intrinsic" {
815
815
/// This will statically either panic, or do nothing.
816
816
///
817
817
/// This intrinsic does not have a stable counterpart.
818
+ #[ rustc_const_unstable( feature = "const_maybe_assume_init" , issue = "none" ) ]
818
819
pub fn assert_inhabited < T > ( ) ;
819
820
820
821
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit
Original file line number Diff line number Diff line change 100
100
#![ feature( const_type_name) ]
101
101
#![ feature( const_likely) ]
102
102
#![ feature( const_unreachable_unchecked) ]
103
+ #![ feature( const_maybe_assume_init) ]
103
104
#![ feature( custom_inner_attributes) ]
104
105
#![ feature( decl_macro) ]
105
106
#![ feature( doc_cfg) ]
Original file line number Diff line number Diff line change @@ -314,8 +314,10 @@ impl<T> MaybeUninit<T> {
314
314
/// let data = read(&mut buf);
315
315
/// ```
316
316
#[ 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
319
#[ inline( always) ]
318
- pub fn uninit_array < const LEN : usize > ( ) -> [ Self ; LEN ] {
320
+ pub const fn uninit_array < const LEN : usize > ( ) -> [ Self ; LEN ] {
319
321
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
320
322
unsafe { MaybeUninit :: < [ MaybeUninit < T > ; LEN ] > :: uninit ( ) . assume_init ( ) }
321
323
}
@@ -503,9 +505,10 @@ impl<T> MaybeUninit<T> {
503
505
/// // `x` had not been initialized yet, so this last line caused undefined behavior. ⚠️
504
506
/// ```
505
507
#[ stable( feature = "maybe_uninit" , since = "1.36.0" ) ]
508
+ #[ rustc_const_unstable( feature = "const_maybe_assume_init" , issue = "none" ) ]
506
509
#[ inline( always) ]
507
510
#[ rustc_diagnostic_item = "assume_init" ]
508
- pub unsafe fn assume_init ( self ) -> T {
511
+ pub const unsafe fn assume_init ( self ) -> T {
509
512
// SAFETY: the caller must guarantee that `self` is initialized.
510
513
// This also means that `self` must be a `value` variant.
511
514
unsafe {
You can’t perform that action at this time.
0 commit comments