Skip to content

Commit f4118d5

Browse files
committed
libsyntax: De-@mut Parser::open_braces
1 parent a2f4877 commit f4118d5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub fn Parser(sess: @mut ParseSess, cfg: ast::CrateConfig, rdr: @mut reader)
318318
quote_depth: 0,
319319
obsolete_set: HashSet::new(),
320320
mod_path_stack: ~[],
321-
open_braces: @mut ~[],
321+
open_braces: ~[],
322322
non_copyable: util::NonCopyable
323323
}
324324
}
@@ -349,7 +349,7 @@ pub struct Parser {
349349
/// Used to determine the path to externally loaded source files
350350
mod_path_stack: ~[@str],
351351
/// Stack of spans of open delimiters. Used for error message.
352-
open_braces: @mut ~[Span],
352+
open_braces: ~[Span],
353353
/* do not copy the parser; its state is tied to outside state */
354354
priv non_copyable: util::NonCopyable
355355
}
@@ -2093,7 +2093,10 @@ impl Parser {
20932093
// This is a conservative error: only report the last unclosed delimiter. The
20942094
// previous unclosed delimiters could actually be closed! The parser just hasn't
20952095
// gotten to them yet.
2096-
p.open_braces.last_opt().map(|sp| p.span_note(*sp, "unclosed delimiter"));
2096+
match p.open_braces.last_opt() {
2097+
None => {}
2098+
Some(&sp) => p.span_note(sp, "unclosed delimiter"),
2099+
};
20972100
let token_str = p.this_token_to_str();
20982101
p.fatal(format!("incorrect close delimiter: `{}`",
20992102
token_str))
@@ -2137,7 +2140,8 @@ impl Parser {
21372140

21382141
match self.token {
21392142
token::EOF => {
2140-
for sp in self.open_braces.iter() {
2143+
let open_braces = self.open_braces.clone();
2144+
for sp in open_braces.iter() {
21412145
self.span_note(*sp, "Did you mean to close this delimiter?");
21422146
}
21432147
// There shouldn't really be a span, but it's easier for the test runner
@@ -2148,7 +2152,7 @@ impl Parser {
21482152
let close_delim = token::flip_delimiter(&self.token);
21492153

21502154
// Parse the open delimiter.
2151-
(*self.open_braces).push(self.span);
2155+
self.open_braces.push(self.span);
21522156
let mut result = ~[parse_any_tt_tok(self)];
21532157

21542158
let trees =

0 commit comments

Comments
 (0)