Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expansion info to crate metadata #43847

Closed
wants to merge 13 commits into from
Closed
Prev Previous commit
Next Next commit
Fixed broken functionality.
However, now that it behaves as expected, the memory usage is
unacceptably high. A solution would be more lazyness during encoding or
a pruning scheme.
  • Loading branch information
ibabushkin committed Oct 7, 2017

Unverified

The committer email address is not verified.
commit 754bf65a3579750ec8227f155e97480af5d67c2c
11 changes: 4 additions & 7 deletions src/libsyntax_pos/hygiene.rs
Original file line number Diff line number Diff line change
@@ -122,6 +122,10 @@ pub struct HygieneData {
gensym_to_ctxt: HashMap<Symbol, SyntaxContext>,
}

thread_local! {
static HYGIENE_DATA: RefCell<HygieneData> = RefCell::new(HygieneData::new());
}

impl HygieneData {
fn new() -> Self {
HygieneData {
@@ -133,17 +137,10 @@ impl HygieneData {
}

fn with<T, F: FnOnce(&mut HygieneData) -> T>(f: F) -> T {
thread_local! {
static HYGIENE_DATA: RefCell<HygieneData> = RefCell::new(HygieneData::new());
}
HYGIENE_DATA.with(|data| f(&mut *data.borrow_mut()))
}

pub fn safe_with<T, F: FnOnce(&HygieneData) -> T>(f: F) -> T {
// FIXME(twk): not sure how this would behave...
thread_local! {
static HYGIENE_DATA: RefCell<HygieneData> = RefCell::new(HygieneData::new());
}
HYGIENE_DATA.with(|data| f(&*data.borrow()))
}
}