@@ -3,9 +3,7 @@ mod tests;
3
3
4
4
use crate :: cell:: UnsafeCell ;
5
5
use crate :: fmt;
6
- use crate :: mem;
7
6
use crate :: ops:: { Deref , DerefMut } ;
8
- use crate :: ptr;
9
7
use crate :: sync:: { poison, LockResult , TryLockError , TryLockResult } ;
10
8
use crate :: sys_common:: mutex as sys;
11
9
@@ -376,23 +374,8 @@ impl<T: ?Sized> Mutex<T> {
376
374
where
377
375
T : Sized ,
378
376
{
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)
396
379
}
397
380
398
381
/// Returns a mutable reference to the underlying data.
0 commit comments