diff options
-rw-r--r-- | crates/ra_prof/src/lib.rs | 8 |
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. |
238 | pub struct Scope { | 238 | pub struct Scope { |
239 | _hidden: (), | 239 | prev: bool, |
240 | } | 240 | } |
241 | 241 | ||
242 | impl Scope { | 242 | impl 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 | ||
252 | impl Drop for Scope { | 252 | impl 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 | ||