Eliminate mut reference UB in Drop impl for Rc<T>
This changes `self.ptr.as_mut()` with `get_mut_unchecked` which does not use an intermediate reference. Arc<T> already handled this case properly.
This commit is contained in:
parent
b4bdc07ff5
commit
493c037699
@ -1195,7 +1195,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
|
||||
self.dec_strong();
|
||||
if self.strong() == 0 {
|
||||
// destroy the contained object
|
||||
ptr::drop_in_place(self.ptr.as_mut());
|
||||
ptr::drop_in_place(Self::get_mut_unchecked(self));
|
||||
|
||||
// remove the implicit "strong weak" pointer now that we've
|
||||
// destroyed the contents.
|
||||
|
Loading…
Reference in New Issue
Block a user