@@ -41,8 +41,6 @@ pub enum SyntaxContext_ {
41
41
EmptyCtxt ,
42
42
Mark ( Mrk , SyntaxContext ) ,
43
43
Rename ( Name ) ,
44
- /// actually, IllegalCtxt may not be necessary.
45
- IllegalCtxt
46
44
}
47
45
48
46
/// A list of ident->name renamings
@@ -99,11 +97,10 @@ pub fn with_sctable<T, F>(op: F) -> T where
99
97
SCTABLE_KEY . with ( move |slot| op ( slot) )
100
98
}
101
99
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.
104
101
fn new_sctable_internal ( ) -> SCTable {
105
102
SCTable {
106
- table : RefCell :: new ( vec ! ( EmptyCtxt , IllegalCtxt ) ) ,
103
+ table : RefCell :: new ( vec ! [ EmptyCtxt ] ) ,
107
104
marks : RefCell :: new ( HashMap :: new ( ) ) ,
108
105
renames : RefCell :: new ( HashMap :: new ( ) ) ,
109
106
}
@@ -129,7 +126,7 @@ pub fn clear_tables() {
129
126
/// Reset the tables to their initial state
130
127
pub fn reset_tables ( ) {
131
128
with_sctable ( |table| {
132
- * table. table . borrow_mut ( ) = vec ! ( EmptyCtxt , IllegalCtxt ) ;
129
+ * table. table . borrow_mut ( ) = vec ! [ EmptyCtxt ] ;
133
130
* table. marks . borrow_mut ( ) = HashMap :: new ( ) ;
134
131
* table. renames . borrow_mut ( ) = HashMap :: new ( ) ;
135
132
} ) ;
@@ -156,7 +153,6 @@ fn resolve_internal(id: Ident, table: &SCTable) -> Name {
156
153
// ignore marks here:
157
154
Mark ( _, subctxt) => resolve_internal ( Ident :: new ( id. name , subctxt) , table) ,
158
155
Rename ( name) => name,
159
- IllegalCtxt => panic ! ( "expected resolvable context, got IllegalCtxt" )
160
156
}
161
157
}
162
158
@@ -192,11 +188,11 @@ mod tests {
192
188
#[ test] fn unfold_marks_test ( ) {
193
189
let mut t = new_sctable_internal ( ) ;
194
190
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 ) ) ;
196
192
{
197
193
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 ) ) ) ;
200
196
}
201
197
}
202
198
@@ -209,10 +205,10 @@ mod tests {
209
205
#[ test]
210
206
fn hashing_tests ( ) {
211
207
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 ) ) ;
214
210
// 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 ) ) ;
216
212
// I'm assuming that the rename table will behave the same....
217
213
}
218
214
}
0 commit comments