@@ -3,15 +3,16 @@ use futures_core::task::{Context, Poll, Waker};
3
3
use slab:: Slab ;
4
4
use std:: { fmt, mem} ;
5
5
use std:: cell:: UnsafeCell ;
6
+ use std:: marker:: PhantomData ;
6
7
use std:: ops:: { Deref , DerefMut } ;
7
8
use std:: pin:: Pin ;
8
9
use std:: sync:: Mutex as StdMutex ;
9
10
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
10
11
11
12
/// A futures-aware mutex.
12
- ///
13
+ ///
13
14
/// # Fairness
14
- ///
15
+ ///
15
16
/// This mutex provides no fairness guarantees. Tasks may not acquire the mutex
16
17
/// in the order that they requested the lock, and it's possible for a single task
17
18
/// which repeatedly takes the lock to starve other tasks, which may be left waiting
@@ -288,7 +289,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
288
289
// Don't run the `drop` method for MutexGuard. The ownership of the underlying
289
290
// locked state is being moved to the returned MappedMutexGuard.
290
291
mem:: forget ( this) ;
291
- MappedMutexGuard { mutex, value }
292
+ MappedMutexGuard { mutex, value, _marker : PhantomData }
292
293
}
293
294
}
294
295
@@ -325,6 +326,7 @@ impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
325
326
pub struct MappedMutexGuard < ' a , T : ?Sized , U : ?Sized > {
326
327
mutex : & ' a Mutex < T > ,
327
328
value : * mut U ,
329
+ _marker : PhantomData < & ' a mut U > ,
328
330
}
329
331
330
332
impl < ' a , T : ?Sized , U : ?Sized > MappedMutexGuard < ' a , T , U > {
@@ -354,7 +356,7 @@ impl<'a, T: ?Sized, U: ?Sized> MappedMutexGuard<'a, T, U> {
354
356
// Don't run the `drop` method for MappedMutexGuard. The ownership of the underlying
355
357
// locked state is being moved to the returned MappedMutexGuard.
356
358
mem:: forget ( this) ;
357
- MappedMutexGuard { mutex, value }
359
+ MappedMutexGuard { mutex, value, _marker : PhantomData }
358
360
}
359
361
}
360
362
@@ -401,8 +403,8 @@ unsafe impl<T: ?Sized> Sync for MutexLockFuture<'_, T> {}
401
403
// lock is essentially spinlock-equivalent (attempt to flip an atomic bool)
402
404
unsafe impl < T : ?Sized + Send > Send for MutexGuard < ' _ , T > { }
403
405
unsafe impl < T : ?Sized + Sync > Sync for MutexGuard < ' _ , T > { }
404
- unsafe impl < T : ?Sized + Send , U : ?Sized > Send for MappedMutexGuard < ' _ , T , U > { }
405
- unsafe impl < T : ?Sized + Sync , U : ?Sized > Sync for MappedMutexGuard < ' _ , T , U > { }
406
+ unsafe impl < T : ?Sized + Send , U : ?Sized + Send > Send for MappedMutexGuard < ' _ , T , U > { }
407
+ unsafe impl < T : ?Sized + Sync , U : ?Sized + Sync > Sync for MappedMutexGuard < ' _ , T , U > { }
406
408
407
409
#[ test]
408
410
fn test_mutex_guard_debug_not_recurse ( ) {
0 commit comments