Skip to content

Commit

Permalink
Emit proper expectation for the "default" keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
qnighy committed May 31, 2017
1 parent 54edfee commit b670930
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3749,6 +3749,16 @@ impl<'a> Parser<'a> {
t.is_keyword(keywords::Pub))
}

fn eat_defaultness(&mut self) -> bool {
let is_defaultness = self.is_defaultness();
if is_defaultness {
self.bump()
} else {
self.expected_tokens.push(TokenType::Keyword(keywords::Default));
}
is_defaultness
}

fn eat_macro_def(&mut self, attrs: &[Attribute], vis: &Visibility)
-> PResult<'a, Option<P<Item>>> {
let lo = self.span;
Expand Down Expand Up @@ -5223,8 +5233,7 @@ impl<'a> Parser<'a> {

/// Parse defaultness: DEFAULT or nothing
fn parse_defaultness(&mut self) -> PResult<'a, Defaultness> {
if self.is_defaultness() {
self.bump();
if self.eat_defaultness() {
Ok(Defaultness::Default)
} else {
Ok(Defaultness::Final)
Expand Down

0 comments on commit b670930

Please sign in to comment.