File tree 2 files changed +4
-12
lines changed
2 files changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -495,10 +495,8 @@ impl<T> Rc<mem::MaybeUninit<T>> {
495
495
#[ unstable( feature = "new_uninit" , issue = "0" ) ]
496
496
#[ inline]
497
497
pub unsafe fn assume_init ( self ) -> Rc < T > {
498
- let ptr = self . ptr . cast ( ) ;
499
- mem:: forget ( self ) ;
500
498
Rc {
501
- ptr,
499
+ ptr : mem :: ManuallyDrop :: new ( self ) . ptr . cast ( ) ,
502
500
phantom : PhantomData ,
503
501
}
504
502
}
@@ -541,10 +539,8 @@ impl<T> Rc<[mem::MaybeUninit<T>]> {
541
539
#[ unstable( feature = "new_uninit" , issue = "0" ) ]
542
540
#[ inline]
543
541
pub unsafe fn assume_init ( self ) -> Rc < [ T ] > {
544
- let ptr = NonNull :: new_unchecked ( self . ptr . as_ptr ( ) as _ ) ;
545
- mem:: forget ( self ) ;
546
542
Rc {
547
- ptr,
543
+ ptr : NonNull :: new_unchecked ( mem :: ManuallyDrop :: new ( self ) . ptr . as_ptr ( ) as _ ) ,
548
544
phantom : PhantomData ,
549
545
}
550
546
}
Original file line number Diff line number Diff line change @@ -479,10 +479,8 @@ impl<T> Arc<mem::MaybeUninit<T>> {
479
479
#[ unstable( feature = "new_uninit" , issue = "0" ) ]
480
480
#[ inline]
481
481
pub unsafe fn assume_init ( self ) -> Arc < T > {
482
- let ptr = self . ptr . cast ( ) ;
483
- mem:: forget ( self ) ;
484
482
Arc {
485
- ptr,
483
+ ptr : mem :: ManuallyDrop :: new ( self ) . ptr . cast ( ) ,
486
484
phantom : PhantomData ,
487
485
}
488
486
}
@@ -525,10 +523,8 @@ impl<T> Arc<[mem::MaybeUninit<T>]> {
525
523
#[ unstable( feature = "new_uninit" , issue = "0" ) ]
526
524
#[ inline]
527
525
pub unsafe fn assume_init ( self ) -> Arc < [ T ] > {
528
- let ptr = NonNull :: new_unchecked ( self . ptr . as_ptr ( ) as _ ) ;
529
- mem:: forget ( self ) ;
530
526
Arc {
531
- ptr,
527
+ ptr : NonNull :: new_unchecked ( mem :: ManuallyDrop :: new ( self ) . ptr . as_ptr ( ) as _ ) ,
532
528
phantom : PhantomData ,
533
529
}
534
530
}
You can’t perform that action at this time.
0 commit comments