From eb790760a266a076bdbff20825a7db2383ae7455 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 5 Nov 2022 19:41:49 +0900 Subject: [PATCH] repo: simplify unsafe cast of view reference --- lib/src/repo.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index c64acc1b0..a6753cd70 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -973,7 +973,6 @@ impl IoResultExt for io::Result { mod dirty_cell { use std::cell::{Cell, RefCell}; - use std::ops::Deref; /// Cell that lazily updates the value after `mark_dirty()`. #[derive(Clone, Debug)] @@ -994,9 +993,7 @@ mod dirty_cell { // SAFETY: get_mut/mark_dirty(&mut self) should invalidate any previously-clean // references leaked by this method. Clean value never changes until then. self.ensure_clean(f); - let borrow = self.value.borrow(); - let temp_ref = borrow.deref(); - unsafe { std::mem::transmute(temp_ref) } + unsafe { &*self.value.as_ptr() } } pub fn ensure_clean(&self, f: impl FnOnce(&mut T)) {