diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-03-07 02:44:10 +0100 | 
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-03-14 11:56:01 +0100 | 
| commit | cbdf4ec03e92ed36c162bb8c645993e48a1caa02 (patch) | |
| tree | d376a0ad7031e5cc10922957eb1575d7e0036b7d /src/libsyntax_pos/span_encoding.rs | |
| parent | fab632f9759af4f3d96c6ec69e24e5428060dba4 (diff) | |
| download | rust-cbdf4ec03e92ed36c162bb8c645993e48a1caa02.tar.gz rust-cbdf4ec03e92ed36c162bb8c645993e48a1caa02.zip | |
Remove syntax and syntax_pos thread locals
Diffstat (limited to 'src/libsyntax_pos/span_encoding.rs')
| -rw-r--r-- | src/libsyntax_pos/span_encoding.rs | 11 | 
1 files changed, 4 insertions, 7 deletions
| diff --git a/src/libsyntax_pos/span_encoding.rs b/src/libsyntax_pos/span_encoding.rs index bf9a832519a..b55fe4bcb26 100644 --- a/src/libsyntax_pos/span_encoding.rs +++ b/src/libsyntax_pos/span_encoding.rs @@ -14,11 +14,11 @@ // The encoding format for inline spans were obtained by optimizing over crates in rustc/libstd. // See https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28 +use GLOBALS; use {BytePos, SpanData}; use hygiene::SyntaxContext; use rustc_data_structures::fx::FxHashMap; -use std::cell::RefCell; use std::hash::{Hash, Hasher}; /// A compressed span. @@ -133,7 +133,7 @@ fn decode(span: Span) -> SpanData { } #[derive(Default)] -struct SpanInterner { +pub struct SpanInterner { spans: FxHashMap<SpanData, u32>, span_data: Vec<SpanData>, } @@ -156,11 +156,8 @@ impl SpanInterner { } } -// If an interner exists in TLS, return it. Otherwise, prepare a fresh one. +// If an interner exists, return it. Otherwise, prepare a fresh one. #[inline] fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T { - thread_local!(static INTERNER: RefCell<SpanInterner> = { - RefCell::new(SpanInterner::default()) - }); - INTERNER.with(|interner| f(&mut *interner.borrow_mut())) + GLOBALS.with(|globals| f(&mut *globals.span_interner.lock())) } | 
