Skip to content

Commit

Permalink
libsyntax: stop early enough if keyword is found instead of ident
Browse files Browse the repository at this point in the history
fixes rust-lang#28439

The signature of public `check_strict_keywords` is changed.
  • Loading branch information
matklad committed Sep 16, 2015
1 parent 0762f58 commit d636258
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ impl<'a> Parser<'a> {
}

pub fn parse_ident(&mut self) -> PResult<ast::Ident> {
self.check_strict_keywords();
try!(self.check_strict_keywords());
try!(self.check_reserved_keywords());
match self.token {
token::Ident(i, _) => {
Expand Down Expand Up @@ -640,13 +640,13 @@ impl<'a> Parser<'a> {
}

/// Signal an error if the given string is a strict keyword
pub fn check_strict_keywords(&mut self) {
pub fn check_strict_keywords(&mut self) -> PResult<()> {
if self.token.is_strict_keyword() {
let token_str = self.this_token_to_string();
let span = self.span;
self.span_err(span,
&format!("expected identifier, found keyword `{}`",
token_str));
Err(self.fatal(&format!("expected identifier, found keyword `{}`",
token_str)))
} else {
Ok(())
}
}

Expand Down

0 comments on commit d636258

Please sign in to comment.