@@ -3447,13 +3447,16 @@ impl<T: Default> Default for Arc { |
|
|
3447 |
3447 |
/// assert_eq!(*x, 0); |
3448 |
3448 |
/// ``` |
3449 |
3449 |
fn default() -> Arc<T> { |
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)) } |
|
3450 |
+unsafe { |
|
3451 |
+Self::from_inner( |
|
3452 |
+Box::leak(Box::write(Box::new_uninit(), ArcInner { |
|
3453 |
+strong: atomic::AtomicUsize::new(1), |
|
3454 |
+weak: atomic::AtomicUsize::new(1), |
|
3455 |
+data: T::default(), |
|
3456 |
+})) |
|
3457 |
+.into(), |
|
3458 |
+) |
|
3459 |
+} |
3457 |
3460 |
} |
3458 |
3461 |
} |
3459 |
3462 |
|