Skip to content

Commit ca92404

Browse files
committed
Remove IllegalCtxt
1 parent 195a27f commit ca92404

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/libsyntax/ext/mtwt.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ pub enum SyntaxContext_ {
4141
EmptyCtxt,
4242
Mark (Mrk,SyntaxContext),
4343
Rename (Name),
44-
/// actually, IllegalCtxt may not be necessary.
45-
IllegalCtxt
4644
}
4745

4846
/// A list of ident->name renamings
@@ -99,11 +97,10 @@ pub fn with_sctable<T, F>(op: F) -> T where
9997
SCTABLE_KEY.with(move |slot| op(slot))
10098
}
10199

102-
// Make a fresh syntax context table with EmptyCtxt in slot zero
103-
// and IllegalCtxt in slot one.
100+
// Make a fresh syntax context table with EmptyCtxt in slot zero.
104101
fn new_sctable_internal() -> SCTable {
105102
SCTable {
106-
table: RefCell::new(vec!(EmptyCtxt, IllegalCtxt)),
103+
table: RefCell::new(vec![EmptyCtxt]),
107104
marks: RefCell::new(HashMap::new()),
108105
renames: RefCell::new(HashMap::new()),
109106
}
@@ -129,7 +126,7 @@ pub fn clear_tables() {
129126
/// Reset the tables to their initial state
130127
pub fn reset_tables() {
131128
with_sctable(|table| {
132-
*table.table.borrow_mut() = vec!(EmptyCtxt, IllegalCtxt);
129+
*table.table.borrow_mut() = vec![EmptyCtxt];
133130
*table.marks.borrow_mut() = HashMap::new();
134131
*table.renames.borrow_mut() = HashMap::new();
135132
});
@@ -156,7 +153,6 @@ fn resolve_internal(id: Ident, table: &SCTable) -> Name {
156153
// ignore marks here:
157154
Mark(_, subctxt) => resolve_internal(Ident::new(id.name, subctxt), table),
158155
Rename(name) => name,
159-
IllegalCtxt => panic!("expected resolvable context, got IllegalCtxt")
160156
}
161157
}
162158

@@ -192,11 +188,11 @@ mod tests {
192188
#[test] fn unfold_marks_test() {
193189
let mut t = new_sctable_internal();
194190

195-
assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),SyntaxContext(3));
191+
assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),SyntaxContext(2));
196192
{
197193
let table = t.table.borrow();
198-
assert!((*table)[2] == Mark(7,EMPTY_CTXT));
199-
assert!((*table)[3] == Mark(3,SyntaxContext(2)));
194+
assert!((*table)[1] == Mark(7,EMPTY_CTXT));
195+
assert!((*table)[2] == Mark(3,SyntaxContext(1)));
200196
}
201197
}
202198

@@ -209,10 +205,10 @@ mod tests {
209205
#[test]
210206
fn hashing_tests () {
211207
let mut t = new_sctable_internal();
212-
assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(2));
213-
assert_eq!(apply_mark_internal(13,EMPTY_CTXT,&mut t),SyntaxContext(3));
208+
assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(1));
209+
assert_eq!(apply_mark_internal(13,EMPTY_CTXT,&mut t),SyntaxContext(2));
214210
// using the same one again should result in the same index:
215-
assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(2));
211+
assert_eq!(apply_mark_internal(12,EMPTY_CTXT,&mut t),SyntaxContext(1));
216212
// I'm assuming that the rename table will behave the same....
217213
}
218214
}

0 commit comments

Comments
 (0)