aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-06-04 12:46:22 +0100
committerAleksey Kladov <[email protected]>2019-06-04 12:46:22 +0100
commitd2b23599b6ac0b79fff0efe4946e098f3f04c1cb (patch)
treefe19e89b6658eabc141a977eed1292757879e03b
parentfcf30d8fa5ef965c7b741c66eb9d25a6781834cb (diff)
fix debug scopes
-rw-r--r--crates/ra_prof/src/lib.rs8
1 files 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<bool> = RefCell::new(false));
236/// Allows to check if the current code is withing some dynamic scope, can be 236/// Allows to check if the current code is withing some dynamic scope, can be
237/// useful during debugging to figure out why a function is called. 237/// useful during debugging to figure out why a function is called.
238pub struct Scope { 238pub struct Scope {
239 _hidden: (), 239 prev: bool,
240} 240}
241 241
242impl Scope { 242impl Scope {
243 pub fn enter() -> Scope { 243 pub fn enter() -> Scope {
244 IN_SCOPE.with(|slot| *slot.borrow_mut() = true); 244 let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true));
245 Scope { _hidden: () } 245 Scope { prev }
246 } 246 }
247 pub fn is_active() -> bool { 247 pub fn is_active() -> bool {
248 IN_SCOPE.with(|slot| *slot.borrow()) 248 IN_SCOPE.with(|slot| *slot.borrow())
@@ -251,7 +251,7 @@ impl Scope {
251 251
252impl Drop for Scope { 252impl Drop for Scope {
253 fn drop(&mut self) { 253 fn drop(&mut self) {
254 IN_SCOPE.with(|slot| *slot.borrow_mut() = false); 254 IN_SCOPE.with(|slot| *slot.borrow_mut() = self.prev);
255 } 255 }
256} 256}
257 257