File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -623,11 +623,11 @@ impl<T> Arc<T> {
623
623
/// ```
624
624
#[ inline]
625
625
#[ unstable( feature = "unwrap_or_drop" , issue = "none" ) ] // FIXME: add issue
626
- // FIXME: should this copy all/some of the comments from drop and drop_slow?
627
626
pub fn unwrap_or_drop ( this : Self ) -> Option < T > {
628
- // following the implementation of `drop` (and `drop_slow`)
627
+ // Make sure that the ordinary `Drop` implementation isn’t called as well
629
628
let mut this = core:: mem:: ManuallyDrop :: new ( this) ;
630
629
630
+ // Following the implementation of `drop` and `drop_slow`
631
631
if this. inner ( ) . strong . fetch_sub ( 1 , Release ) != 1 {
632
632
return None ;
633
633
}
@@ -637,7 +637,13 @@ impl<T> Arc<T> {
637
637
// FIXME: should the part below this be moved into a seperate #[inline(never)]
638
638
// function, like it's done with drop_slow in drop?
639
639
640
- // using `ptr::read` where `drop_slow` was using `ptr::drop_in_place`
640
+ // SAFETY: This mirrors the line
641
+ //
642
+ // unsafe { ptr::drop_in_place(Self::get_mut_unchecked(self)) };
643
+ //
644
+ // in `drop_slow`. Instead of dropping the value behind the pointer
645
+ // it is read and eventually returned; `ptr::read` has the same
646
+ // safety conditions as `ptr::drop_in_place`.
641
647
let inner = unsafe { ptr:: read ( Self :: get_mut_unchecked ( & mut this) ) } ;
642
648
643
649
drop ( Weak { ptr : this. ptr } ) ;
You can’t perform that action at this time.
0 commit comments