diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-04 12:47:32 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-04 12:47:32 +0100 |
commit | 8bd0e844247dc28d6ceb24b00f3cc3396bd5bf03 (patch) | |
tree | fe19e89b6658eabc141a977eed1292757879e03b /crates | |
parent | fcf30d8fa5ef965c7b741c66eb9d25a6781834cb (diff) | |
parent | d2b23599b6ac0b79fff0efe4946e098f3f04c1cb (diff) |
Merge #1376
1376: fix debug scopes r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-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 | ||