From d2b23599b6ac0b79fff0efe4946e098f3f04c1cb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 4 Jun 2019 14:46:22 +0300 Subject: fix debug scopes --- crates/ra_prof/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 6ec24d86d..de67b4031 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -236,13 +236,13 @@ thread_local!(static IN_SCOPE: RefCell = RefCell::new(false)); /// Allows to check if the current code is withing some dynamic scope, can be /// useful during debugging to figure out why a function is called. pub struct Scope { - _hidden: (), + prev: bool, } impl Scope { pub fn enter() -> Scope { - IN_SCOPE.with(|slot| *slot.borrow_mut() = true); - Scope { _hidden: () } + let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true)); + Scope { prev } } pub fn is_active() -> bool { IN_SCOPE.with(|slot| *slot.borrow()) @@ -251,7 +251,7 @@ impl Scope { impl Drop for Scope { fn drop(&mut self) { - IN_SCOPE.with(|slot| *slot.borrow_mut() = false); + IN_SCOPE.with(|slot| *slot.borrow_mut() = self.prev); } } -- cgit v1.2.3