Skip to content

Commit 4269f85

Browse files
committed
libsyntax: De-@mut name_idx
1 parent 449ebee commit 4269f85

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ use parse::{new_sub_parser_from_file, ParseSess};
8181
use opt_vec;
8282
use opt_vec::OptVec;
8383

84+
use std::cell::Cell;
8485
use std::hashmap::HashSet;
8586
use std::util;
8687
use std::vec;
@@ -2185,7 +2186,7 @@ impl Parser {
21852186
// unification of matchers and token_trees would vastly improve
21862187
// the interpolation of matchers
21872188
maybe_whole!(self, nt_matchers);
2188-
let name_idx = @mut 0u;
2189+
let name_idx = @Cell::new(0u);
21892190
match self.token {
21902191
token::LBRACE | token::LPAREN | token::LBRACKET => {
21912192
let other_delimiter = token::flip_delimiter(&self.token);
@@ -2200,7 +2201,7 @@ impl Parser {
22002201
// Otherwise, `$( ( )` would be a valid matcher, and `$( () )` would be
22012202
// invalid. It's similar to common::parse_seq.
22022203
pub fn parse_matcher_subseq_upto(&mut self,
2203-
name_idx: @mut uint,
2204+
name_idx: @Cell<uint>,
22042205
ket: &token::Token)
22052206
-> ~[matcher] {
22062207
let mut ret_val = ~[];
@@ -2217,27 +2218,27 @@ impl Parser {
22172218
return ret_val;
22182219
}
22192220

2220-
pub fn parse_matcher(&mut self, name_idx: @mut uint) -> matcher {
2221+
pub fn parse_matcher(&mut self, name_idx: @Cell<uint>) -> matcher {
22212222
let lo = self.span.lo;
22222223

22232224
let m = if self.token == token::DOLLAR {
22242225
self.bump();
22252226
if self.token == token::LPAREN {
2226-
let name_idx_lo = *name_idx;
2227+
let name_idx_lo = name_idx.get();
22272228
self.bump();
22282229
let ms = self.parse_matcher_subseq_upto(name_idx,
22292230
&token::RPAREN);
22302231
if ms.len() == 0u {
22312232
self.fatal("repetition body must be nonempty");
22322233
}
22332234
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())
22352236
} else {
22362237
let bound_to = self.parse_ident();
22372238
self.expect(&token::COLON);
22382239
let nt_name = self.parse_ident();
2239-
let m = match_nonterminal(bound_to, nt_name, *name_idx);
2240-
*name_idx += 1u;
2240+
let m = match_nonterminal(bound_to, nt_name, name_idx.get());
2241+
name_idx.set(name_idx.get() + 1u);
22412242
m
22422243
}
22432244
} else {

0 commit comments

Comments
 (0)