about summary refs log tree commit diff
path: root/src/libsyntax_pos/lib.rs
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-03-07 02:44:10 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-03-14 11:56:01 +0100
commitcbdf4ec03e92ed36c162bb8c645993e48a1caa02 (patch)
treed376a0ad7031e5cc10922957eb1575d7e0036b7d /src/libsyntax_pos/lib.rs
parentfab632f9759af4f3d96c6ec69e24e5428060dba4 (diff)
downloadrust-cbdf4ec03e92ed36c162bb8c645993e48a1caa02.tar.gz
rust-cbdf4ec03e92ed36c162bb8c645993e48a1caa02.zip
Remove syntax and syntax_pos thread locals
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
-rw-r--r--src/libsyntax_pos/lib.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index ed9eb5d5c92..bec46ff3d79 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -35,10 +35,13 @@ use std::ops::{Add, Sub};
 use std::path::PathBuf;
 
 use rustc_data_structures::stable_hasher::StableHasher;
-use rustc_data_structures::sync::Lrc;
+use rustc_data_structures::sync::{Lrc, Lock};
 
 extern crate rustc_data_structures;
 
+#[macro_use]
+extern crate scoped_tls;
+
 use serialize::{Encodable, Decodable, Encoder, Decoder};
 
 extern crate serialize;
@@ -54,6 +57,24 @@ pub use span_encoding::{Span, DUMMY_SP};
 
 pub mod symbol;
 
+pub struct Globals {
+    symbol_interner: Lock<symbol::Interner>,
+    span_interner: Lock<span_encoding::SpanInterner>,
+    hygiene_data: Lock<hygiene::HygieneData>,
+}
+
+impl Globals {
+    pub fn new() -> Globals {
+        Globals {
+            symbol_interner: Lock::new(symbol::Interner::fresh()),
+            span_interner: Lock::new(span_encoding::SpanInterner::default()),
+            hygiene_data: Lock::new(hygiene::HygieneData::new()),
+        }
+    }
+}
+
+scoped_thread_local!(pub static GLOBALS: Globals);
+
 /// Differentiates between real files and common virtual files
 #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)]
 pub enum FileName {