@@ -17,6 +17,7 @@ use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident};
17
17
use parse:: token:: { ident_to_str} ;
18
18
use parse:: lexer:: TokenAndSpan ;
19
19
20
+ use std:: cell:: RefCell ;
20
21
use std:: hashmap:: HashMap ;
21
22
use std:: option;
22
23
@@ -34,7 +35,7 @@ pub struct TtReader {
34
35
// the unzipped tree:
35
36
stack : @mut TtFrame ,
36
37
/* for MBE-style macro transcription */
37
- interpolations : HashMap < Ident , @named_match > ,
38
+ priv interpolations : RefCell < HashMap < Ident , @named_match > > ,
38
39
repeat_idx : ~[ uint ] ,
39
40
repeat_len : ~[ uint ] ,
40
41
/* cached: */
@@ -59,8 +60,8 @@ pub fn new_tt_reader(sp_diag: @mut SpanHandler,
59
60
up : option:: None
60
61
} ,
61
62
interpolations : match interp { /* just a convienience */
62
- None => HashMap :: new ( ) ,
63
- Some ( x) => x
63
+ None => RefCell :: new ( HashMap :: new ( ) ) ,
64
+ Some ( x) => RefCell :: new ( x ) ,
64
65
} ,
65
66
repeat_idx : ~[ ] ,
66
67
repeat_len : ~[ ] ,
@@ -114,7 +115,11 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader,
114
115
}
115
116
116
117
fn lookup_cur_matched ( r : & mut TtReader , name : Ident ) -> @named_match {
117
- match r. interpolations . find_copy ( & name) {
118
+ let matched_opt = {
119
+ let interpolations = r. interpolations . borrow ( ) ;
120
+ interpolations. get ( ) . find_copy ( & name)
121
+ } ;
122
+ match matched_opt {
118
123
Some ( s) => lookup_cur_matched_by_matched ( r, s) ,
119
124
None => {
120
125
r. sp_diag . span_fatal ( r. cur_span , format ! ( "unknown macro variable `{}`" ,
0 commit comments