From 69e5729c58481e1a2ce4e4a5982d38deab1fc6b2 Mon Sep 17 00:00:00 2001 From: Daniel Henry-Mantilla Date: Wed, 4 Nov 2020 14:54:22 +0100 Subject: [PATCH] Simplify the implementation of `get_mut` (no unsafe) --- library/core/src/cell.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 7140218fa91..ef2a5dd570f 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1733,8 +1733,7 @@ impl UnsafeCell { #[inline] #[unstable(feature = "unsafe_cell_get_mut", issue = "76943")] pub fn get_mut(&mut self) -> &mut T { - // SAFETY: (outer) `&mut` guarantees unique access. - unsafe { &mut *self.get() } + &mut self.value } /// Gets a mutable pointer to the wrapped value.