File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 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> {
623623 /// ```
624624 #[ inline]
625625 #[ 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?
627626 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
629628 let mut this = core:: mem:: ManuallyDrop :: new ( this) ;
630629
630+ // Following the implementation of `drop` and `drop_slow`
631631 if this. inner ( ) . strong . fetch_sub ( 1 , Release ) != 1 {
632632 return None ;
633633 }
@@ -637,7 +637,13 @@ impl<T> Arc<T> {
637637 // FIXME: should the part below this be moved into a seperate #[inline(never)]
638638 // function, like it's done with drop_slow in drop?
639639
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`.
641647 let inner = unsafe { ptr:: read ( Self :: get_mut_unchecked ( & mut this) ) } ;
642648
643649 drop ( Weak { ptr : this. ptr } ) ;
You can’t perform that action at this time.
0 commit comments