@@ -3,9 +3,7 @@ mod tests;
33
44use crate :: cell:: UnsafeCell ;
55use crate :: fmt;
6- use crate :: mem;
76use crate :: ops:: { Deref , DerefMut } ;
8- use crate :: ptr;
97use crate :: sync:: { poison, LockResult , TryLockError , TryLockResult } ;
108use crate :: sys_common:: mutex as sys;
119
@@ -376,23 +374,8 @@ impl<T: ?Sized> Mutex<T> {
376374 where
377375 T : Sized ,
378376 {
379- // We know statically that there are no outstanding references to
380- // `self` so there's no need to lock the inner mutex.
381- //
382- // To get the inner value, we'd like to call `data.into_inner()`,
383- // but because `Mutex` impl-s `Drop`, we can't move out of it, so
384- // we'll have to destructure it manually instead.
385- unsafe {
386- // Like `let Mutex { inner, poison, data } = self`.
387- let ( inner, poison, data) = {
388- let Mutex { ref inner, ref poison, ref data } = self ;
389- ( ptr:: read ( inner) , ptr:: read ( poison) , ptr:: read ( data) )
390- } ;
391- mem:: forget ( self ) ;
392- drop ( inner) ;
393-
394- poison:: map_result ( poison. borrow ( ) , |_| data. into_inner ( ) )
395- }
377+ let data = self . data . into_inner ( ) ;
378+ poison:: map_result ( self . poison . borrow ( ) , |_| data)
396379 }
397380
398381 /// Returns a mutable reference to the underlying data.
0 commit comments