diff options
| author | Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com> | 2020-09-19 21:33:40 +0200 |
|---|---|---|
| committer | Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com> | 2020-09-20 18:06:03 +0200 |
| commit | 5886c38112c8bb347b1cbd46c28b1ca6f8bac88d (patch) | |
| tree | 04dfeb868a19be6a6d953c8756242d0530a99bfe /library/std | |
| parent | 81699895073162cd6731413711a4357dde67d661 (diff) | |
| download | rust-5886c38112c8bb347b1cbd46c28b1ca6f8bac88d.tar.gz rust-5886c38112c8bb347b1cbd46c28b1ca6f8bac88d.zip | |
Replace unneeded `unsafe` calls to `.get()` with calls to `.get_mut()`
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sync/mutex.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sync/rwlock.rs | 4 |
3 files changed, 3 insertions, 6 deletions
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 5333d75ec1b..71b29cf5af9 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -315,6 +315,7 @@ #![feature(try_reserve)] #![feature(unboxed_closures)] #![feature(unsafe_block_in_unsafe_fn)] +#![feature(unsafe_cell_get_mut)] #![feature(unsafe_cell_raw_get)] #![feature(untagged_unions)] #![feature(unwind_attributes)] diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 240155b06b4..a1703c731d4 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -406,9 +406,7 @@ impl<T: ?Sized> Mutex<T> { /// ``` #[stable(feature = "mutex_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { - // We know statically that there are no other references to `self`, so - // there's no need to lock the inner mutex. - let data = unsafe { &mut *self.data.get() }; + let data = self.data.get_mut(); poison::map_result(self.poison.borrow(), |_| data) } } diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index f38d6101da0..d967779ce36 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -404,9 +404,7 @@ impl<T: ?Sized> RwLock<T> { /// ``` #[stable(feature = "rwlock_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { - // We know statically that there are no other references to `self`, so - // there's no need to lock the inner lock. - let data = unsafe { &mut *self.data.get() }; + let data = self.data.get_mut(); poison::map_result(self.poison.borrow(), |_| data) } } |
