about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-06-22 02:49:31 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-07-14 01:30:22 +0000
commitca924047de90b1370a7f1a81df7cfb611fe59b44 (patch)
tree3cbbe771a3dd9e45fd73eb2ae59a2b852cb00faa /src/libsyntax
parent195a27faab593c8cbfd6ac5389f578100074df13 (diff)
downloadrust-ca924047de90b1370a7f1a81df7cfb611fe59b44.tar.gz
rust-ca924047de90b1370a7f1a81df7cfb611fe59b44.zip
Remove `IllegalCtxt`
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/mtwt.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs
index c9e8715dda6..0f569575d58 100644
--- a/src/libsyntax/ext/mtwt.rs
+++ b/src/libsyntax/ext/mtwt.rs
@@ -41,8 +41,6 @@ pub enum SyntaxContext_ {
     EmptyCtxt,
     Mark (Mrk,SyntaxContext),
     Rename (Name),
-    /// actually, IllegalCtxt may not be necessary.
-    IllegalCtxt
 }
 
 /// A list of ident->name renamings
@@ -99,11 +97,10 @@ pub fn with_sctable<T, F>(op: F) -> T where
     SCTABLE_KEY.with(move |slot| op(slot))
 }
 
-// Make a fresh syntax context table with EmptyCtxt in slot zero
-// and IllegalCtxt in slot one.
+// Make a fresh syntax context table with EmptyCtxt in slot zero.
 fn new_sctable_internal() -> SCTable {
     SCTable {
-        table: RefCell::new(vec!(EmptyCtxt, IllegalCtxt)),
+        table: RefCell::new(vec![EmptyCtxt]),
         marks: RefCell::new(HashMap::new()),
         renames: RefCell::new(HashMap::new()),
     }
@@ -129,7 +126,7 @@ pub fn clear_tables() {
 /// Reset the tables to their initial state
 pub fn reset_tables() {
     with_sctable(|table| {
-        *table.table.borrow_mut() = vec!(EmptyCtxt, IllegalCtxt);
+        *table.table.borrow_mut() = vec![EmptyCtxt];
         *table.marks.borrow_mut() = HashMap::new();
         *table.renames.borrow_mut() = HashMap::new();
     });
@@ -156,7 +153,6 @@ fn resolve_internal(id: Ident, table: &SCTable) -> Name {
         // ignore marks here:
         Mark(_, subctxt) => resolve_internal(Ident::new(id.name, subctxt), table),
         Rename(name) => name,
-        IllegalCtxt => panic!("expected resolvable context, got IllegalCtxt")
     }
 }
 
@@ -192,11 +188,11 @@ mod tests {
     #[test] fn unfold_marks_test() {
         let mut t = new_sctable_internal();
 
-        assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),SyntaxContext(3));
+        assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),SyntaxContext(2));
         {
             let table = t.table.borrow();
-            assert!((*table)[2] == Mark(7,EMPTY_CTXT));
-            assert!((*table)[3] == Mark(3,SyntaxContext(2)));
+            assert!((*table)[1] == Mark(7,EMPTY_CTXT));
+            assert!((*table)[2] == Mark(3,SyntaxContext(1)));
         }
     }
 
@@ -209,10 +205,10 @@ mod tests {
     #[test]
     fn hashing_tests () {
         let mut t = new_sctable_internal();
-        assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(2));
-        assert_eq!(apply_mark_internal(13,EMPTY_CTXT,&mut t),SyntaxContext(3));
+        assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(1));
+        assert_eq!(apply_mark_internal(13,EMPTY_CTXT,&mut t),SyntaxContext(2));
         // using the same one again should result in the same index:
-        assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(2));
+        assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(1));
         // I'm assuming that the rename table will behave the same....
     }
 }