File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11
11
#![ feature( cfg_target_has_atomic) ]
12
12
#![ feature( const_assume) ]
13
13
#![ feature( const_cell_into_inner) ]
14
+ #![ feature( const_maybe_uninit_assume_init) ]
14
15
#![ feature( core_intrinsics) ]
15
16
#![ feature( core_private_bignum) ]
16
17
#![ feature( core_private_diy_float) ]
53
54
#![ feature( const_pin) ]
54
55
#![ feature( const_slice_from_raw_parts) ]
55
56
#![ feature( const_raw_ptr_deref) ]
57
+ #![ feature( const_assert_type) ]
56
58
#![ feature( never_type) ]
57
59
#![ feature( unwrap_infallible) ]
58
60
#![ feature( option_unwrap_none) ]
Original file line number Diff line number Diff line change @@ -132,18 +132,17 @@ fn test_discriminant_send_sync() {
132
132
133
133
#[ test]
134
134
fn assume_init_good ( ) {
135
- const TRUE : bool = unsafe {
136
- let mut x = MaybeUninit :: < bool > :: uninit ( ) ;
137
- x. as_mut_ptr ( ) . write ( true ) ;
138
- x. assume_init ( )
139
- } ;
135
+ const TRUE : bool = unsafe { MaybeUninit :: < bool > :: new ( true ) . assume_init ( ) } ;
136
+
140
137
assert ! ( TRUE ) ;
141
138
}
142
139
143
140
#[ test]
144
- #[ should_panic]
145
141
fn assume_init_bad ( ) {
146
- const BAD : ( ) = unsafe {
142
+ const _BAD : ( ) = unsafe {
147
143
MaybeUninit :: < !> :: uninit ( ) . assume_init ( ) ;
144
+ //~^ ERROR the type `!` does not permit being left uninitialized
145
+ //~| ERROR this code causes undefined behavior when executed
146
+ //~| ERROR help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
148
147
} ;
149
148
}
You can’t perform that action at this time.
0 commit comments