about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMurarth <murarth@gmail.com>2014-11-28 21:56:09 -0700
committerMurarth <murarth@gmail.com>2014-11-29 09:50:48 -0700
commit004533ea755ecfc5d65e282366aaffc523e9632c (patch)
tree6da61627cfc0439e7eb220413eceed153be01df2 /src/libsyntax
parent29e928f2ba3501d37660314f6186d0e2ac18b9db (diff)
downloadrust-004533ea755ecfc5d65e282366aaffc523e9632c.tar.gz
rust-004533ea755ecfc5d65e282366aaffc523e9632c.zip
Fix rustc panic on second compile_input
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/mtwt.rs10
-rw-r--r--src/libsyntax/parse/token.rs6
-rw-r--r--src/libsyntax/util/interner.rs5
3 files changed, 21 insertions, 0 deletions
diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs
index e6d886e28ba..6ba90bbebed 100644
--- a/src/libsyntax/ext/mtwt.rs
+++ b/src/libsyntax/ext/mtwt.rs
@@ -136,6 +136,16 @@ pub fn clear_tables() {
     with_resolve_table_mut(|table| *table = HashMap::new());
 }
 
+/// Reset the tables to their initial state
+pub fn reset_tables() {
+    with_sctable(|table| {
+        *table.table.borrow_mut() = vec!(EmptyCtxt, IllegalCtxt);
+        *table.mark_memo.borrow_mut() = HashMap::new();
+        *table.rename_memo.borrow_mut() = HashMap::new();
+    });
+    with_resolve_table_mut(|table| *table = HashMap::new());
+}
+
 /// Add a value to the end of a vec, return its index
 fn idx_push<T>(vec: &mut Vec<T>, val: T) -> u32 {
     vec.push(val);
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 583ace977fe..37df2bf14c2 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -564,6 +564,12 @@ pub fn get_ident_interner() -> Rc<IdentInterner> {
     KEY.with(|k| k.clone())
 }
 
+/// Reset the ident interner to its initial state.
+pub fn reset_ident_interner() {
+    let interner = get_ident_interner();
+    interner.reset(mk_fresh_ident_interner());
+}
+
 /// Represents a string stored in the task-local interner. Because the
 /// interner lives for the life of the task, this can be safely treated as an
 /// immortal string, as long as it never crosses between tasks.
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index ede967bba25..590a04ce221 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -214,6 +214,11 @@ impl StrInterner {
         *self.map.borrow_mut() = HashMap::new();
         *self.vect.borrow_mut() = Vec::new();
     }
+
+    pub fn reset(&self, other: StrInterner) {
+        *self.map.borrow_mut() = other.map.into_inner();
+        *self.vect.borrow_mut() = other.vect.into_inner();
+    }
 }
 
 #[cfg(test)]