mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
fix debug scopes
This commit is contained in:
parent
fcf30d8fa5
commit
d2b23599b6
1 changed files with 4 additions and 4 deletions
|
@ -236,13 +236,13 @@ thread_local!(static IN_SCOPE: RefCell<bool> = RefCell::new(false));
|
||||||
/// Allows to check if the current code is withing some dynamic scope, can be
|
/// 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.
|
/// useful during debugging to figure out why a function is called.
|
||||||
pub struct Scope {
|
pub struct Scope {
|
||||||
_hidden: (),
|
prev: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scope {
|
impl Scope {
|
||||||
pub fn enter() -> Scope {
|
pub fn enter() -> Scope {
|
||||||
IN_SCOPE.with(|slot| *slot.borrow_mut() = true);
|
let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true));
|
||||||
Scope { _hidden: () }
|
Scope { prev }
|
||||||
}
|
}
|
||||||
pub fn is_active() -> bool {
|
pub fn is_active() -> bool {
|
||||||
IN_SCOPE.with(|slot| *slot.borrow())
|
IN_SCOPE.with(|slot| *slot.borrow())
|
||||||
|
@ -251,7 +251,7 @@ impl Scope {
|
||||||
|
|
||||||
impl Drop for Scope {
|
impl Drop for Scope {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
IN_SCOPE.with(|slot| *slot.borrow_mut() = false);
|
IN_SCOPE.with(|slot| *slot.borrow_mut() = self.prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue