File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,10 @@ unsafe impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T> {}
245
245
#[ unstable( feature = "mapped_lock_guards" , issue = "none" ) ]
246
246
#[ clippy:: has_significant_drop]
247
247
pub struct MappedMutexGuard < ' a , T : ?Sized + ' a > {
248
+ // NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a
249
+ // `MappedMutexGuard` argument doesn't hold uniqueness for its whole scope, only until it drops.
250
+ // `NonNull` is covariant over `T`, so we add a `PhantomData<&'a mut T>` field
251
+ // below for the correct variance over `T` (invariance).
248
252
data : NonNull < T > ,
249
253
inner_state : & ' a MutexState ,
250
254
poison : poison:: Guard ,
Original file line number Diff line number Diff line change @@ -194,6 +194,10 @@ unsafe impl<T: ?Sized + Sync> Sync for MappedRwLockReadGuard<'_, T> {}
194
194
#[ unstable( feature = "mapped_lock_guards" , issue = "none" ) ]
195
195
#[ clippy:: has_significant_drop]
196
196
pub struct MappedRwLockWriteGuard < ' a , T : ?Sized + ' a > {
197
+ // NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a
198
+ // `MappedRwLockWriteGuard` argument doesn't hold uniqueness for its whole scope, only until it drops.
199
+ // `NonNull` is covariant over `T`, so we add a `PhantomData<&'a mut T>` field
200
+ // below for the correct variance over `T` (invariance).
197
201
data : NonNull < T > ,
198
202
inner_state : & ' a RwLockState ,
199
203
poison : poison:: Guard ,
You can’t perform that action at this time.
0 commit comments