File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 104104#![ feature( async_closure) ]
105105#![ feature( async_fn_traits) ]
106106#![ feature( async_iterator) ]
107+ #![ feature( box_uninit_write) ]
107108#![ feature( clone_to_uninit) ]
108109#![ feature( coerce_unsized) ]
109110#![ feature( const_align_of_val) ]
Original file line number Diff line number Diff line change @@ -3447,7 +3447,13 @@ impl<T: Default> Default for Arc<T> {
34473447 /// assert_eq!(*x, 0);
34483448 /// ```
34493449 fn default ( ) -> Arc < T > {
3450- Arc :: new ( Default :: default ( ) )
3450+ let x = Box :: into_raw ( Box :: write ( Box :: new_uninit ( ) , ArcInner {
3451+ strong : atomic:: AtomicUsize :: new ( 1 ) ,
3452+ weak : atomic:: AtomicUsize :: new ( 1 ) ,
3453+ data : T :: default ( ) ,
3454+ } ) ) ;
3455+ // SAFETY: `Box::into_raw` consumes the `Box` and never returns null
3456+ unsafe { Self :: from_inner ( NonNull :: new_unchecked ( x) ) }
34513457 }
34523458}
34533459
You can’t perform that action at this time.
0 commit comments