From f62aafa79f0a39dd9a0f539e5f0d73dd35b2ebb2 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 4 Nov 2022 20:28:03 +0900 Subject: [PATCH] repo: comment about safety implication of view/view_dirty --- lib/src/repo.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index e1899e9c7..f5d2d1c3b 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -506,6 +506,10 @@ impl MutableRepo { } pub fn view(&self) -> &View { + // SAFETY: We don't really rely on runtime Ref/RefMut tracking. Since view_dirty + // is set only by &mut self functions, and view() is the solo function which + // publicly provides view-related reference, there should be no view reference + // alive if view_dirty == true. self.enforce_view_invariants(); let view_borrow = self.view.borrow(); let view = view_borrow.deref();