]> git.lizzy.rs Git - rust.git/commitdiff
Address comments
authorRobin Raymond <robin@robinraymond.de>
Fri, 13 May 2022 07:18:57 +0000 (07:18 +0000)
committerRobin Raymond <robin@robinraymond.de>
Sun, 19 Jun 2022 07:22:40 +0000 (09:22 +0200)
library/std/src/sync/rwlock.rs

index 22207b266fa65ed8a8d9e748fd1ae1a06faf7d15..ac3c3b509cde6dfb11b8d2d4773f1c0904d3a63d 100644 (file)
@@ -101,8 +101,8 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
 #[stable(feature = "rust1", since = "1.0.0")]
 #[clippy::has_significant_drop]
 pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
+    data: *const T,
     inner_lock: &'a sys::MovableRwLock,
-    data: &'a T,
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -513,7 +513,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
     unsafe fn new(lock: &'rwlock RwLock<T>) -> LockResult<RwLockReadGuard<'rwlock, T>> {
         poison::map_result(lock.poison.borrow(), |()| RwLockReadGuard {
             inner_lock: &lock.inner,
-            data: &*lock.data.get(),
+            data: lock.data.get(),
         })
     }
 }
@@ -557,7 +557,7 @@ impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> {
     type Target = T;
 
     fn deref(&self) -> &T {
-        self.data
+        unsafe { &*self.data }
     }
 }