about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-30 13:12:36 +0100
committerGitHub <noreply@github.com>2021-12-30 13:12:36 +0100
commitc10fe04484e90ef32b5b8b9b9428a45fd6a8bb77 (patch)
tree3a7849965a283ac0c0226dc628634ace58a3623b
parenta23ef617b32efee0e761a1ac6f548642e4704361 (diff)
parente86ecdf9fe2d60dad52c1e60657ed749c2196c5b (diff)
downloadrust-c10fe04484e90ef32b5b8b9b9428a45fd6a8bb77.tar.gz
rust-c10fe04484e90ef32b5b8b9b9428a45fd6a8bb77.zip
Rollup merge of #92427 - ChayimFriedman2:patch-1, r=kennytm
Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`

This removes one unnecessary `unsafe` block.
-rw-r--r--library/core/src/lazy.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/library/core/src/lazy.rs b/library/core/src/lazy.rs
index 2b8a5f3cbf3..788f0cce01b 100644
--- a/library/core/src/lazy.rs
+++ b/library/core/src/lazy.rs
@@ -102,8 +102,7 @@ impl<T> OnceCell<T> {
     /// Returns `None` if the cell is empty.
     #[unstable(feature = "once_cell", issue = "74465")]
     pub fn get_mut(&mut self) -> Option<&mut T> {
-        // SAFETY: Safe because we have unique access
-        unsafe { &mut *self.inner.get() }.as_mut()
+        self.inner.get_mut().as_mut()
     }
 
     /// Sets the contents of the cell to `value`.