@@ -81,6 +81,7 @@ use parse::{new_sub_parser_from_file, ParseSess};
81
81
use opt_vec;
82
82
use opt_vec:: OptVec ;
83
83
84
+ use std:: cell:: Cell ;
84
85
use std:: hashmap:: HashSet ;
85
86
use std:: util;
86
87
use std:: vec;
@@ -2185,7 +2186,7 @@ impl Parser {
2185
2186
// unification of matchers and token_trees would vastly improve
2186
2187
// the interpolation of matchers
2187
2188
maybe_whole ! ( self , nt_matchers) ;
2188
- let name_idx = @mut 0 u ;
2189
+ let name_idx = @Cell :: new ( 0 u ) ;
2189
2190
match self . token {
2190
2191
token:: LBRACE | token:: LPAREN | token:: LBRACKET => {
2191
2192
let other_delimiter = token:: flip_delimiter ( & self . token ) ;
@@ -2200,7 +2201,7 @@ impl Parser {
2200
2201
// Otherwise, `$( ( )` would be a valid matcher, and `$( () )` would be
2201
2202
// invalid. It's similar to common::parse_seq.
2202
2203
pub fn parse_matcher_subseq_upto ( & mut self ,
2203
- name_idx : @mut uint ,
2204
+ name_idx : @Cell < uint > ,
2204
2205
ket : & token:: Token )
2205
2206
-> ~[ matcher ] {
2206
2207
let mut ret_val = ~[ ] ;
@@ -2217,27 +2218,27 @@ impl Parser {
2217
2218
return ret_val;
2218
2219
}
2219
2220
2220
- pub fn parse_matcher ( & mut self , name_idx : @mut uint ) -> matcher {
2221
+ pub fn parse_matcher ( & mut self , name_idx : @Cell < uint > ) -> matcher {
2221
2222
let lo = self . span . lo ;
2222
2223
2223
2224
let m = if self . token == token:: DOLLAR {
2224
2225
self . bump ( ) ;
2225
2226
if self . token == token:: LPAREN {
2226
- let name_idx_lo = * name_idx;
2227
+ let name_idx_lo = name_idx. get ( ) ;
2227
2228
self . bump ( ) ;
2228
2229
let ms = self . parse_matcher_subseq_upto ( name_idx,
2229
2230
& token:: RPAREN ) ;
2230
2231
if ms. len ( ) == 0 u {
2231
2232
self . fatal ( "repetition body must be nonempty" ) ;
2232
2233
}
2233
2234
let ( sep, zerok) = self . parse_sep_and_zerok ( ) ;
2234
- match_seq ( ms, sep, zerok, name_idx_lo, * name_idx)
2235
+ match_seq ( ms, sep, zerok, name_idx_lo, name_idx. get ( ) )
2235
2236
} else {
2236
2237
let bound_to = self . parse_ident ( ) ;
2237
2238
self . expect ( & token:: COLON ) ;
2238
2239
let nt_name = self . parse_ident ( ) ;
2239
- let m = match_nonterminal ( bound_to, nt_name, * name_idx) ;
2240
- * name_idx += 1 u;
2240
+ let m = match_nonterminal ( bound_to, nt_name, name_idx. get ( ) ) ;
2241
+ name_idx. set ( name_idx . get ( ) + 1 u) ;
2241
2242
m
2242
2243
}
2243
2244
} else {
0 commit comments