Skip to content

Commit 754bf65

Browse files
committed
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.
1 parent 64934ba commit 754bf65

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/libsyntax_pos/hygiene.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ pub struct HygieneData {
122122
gensym_to_ctxt: HashMap<Symbol, SyntaxContext>,
123123
}
124124

125+
thread_local! {
126+
static HYGIENE_DATA: RefCell<HygieneData> = RefCell::new(HygieneData::new());
127+
}
128+
125129
impl HygieneData {
126130
fn new() -> Self {
127131
HygieneData {
@@ -133,17 +137,10 @@ impl HygieneData {
133137
}
134138

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

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

0 commit comments

Comments
 (0)