From b670930933fd8af2316364d4e15e6a22983cf78d Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Wed, 31 May 2017 23:22:33 +0900 Subject: [PATCH] Emit proper expectation for the "default" keyword. --- src/libsyntax/parse/parser.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 63fe33b8754d3..936a2e8b2e1be 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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>> { let lo = self.span; @@ -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)