aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_prof/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_prof/src')
-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