Consume trailing doc comments to avoid parse errors

This commit is contained in:
Esteban Küber
2017-11-24 07:34:24 -08:00
parent 0e93b75d27
commit f103342b8f
3 changed files with 13 additions and 6 deletions

View File

@@ -5422,9 +5422,8 @@ impl<'a> Parser<'a> {
token::CloseDelim(token::Brace) => {}
token::DocComment(_) => {
let mut err = self.span_fatal_err(self.span, Error::UselessDocComment);
if self.eat(&token::Comma) ||
self.look_ahead(1, |t| *t == token::CloseDelim(token::Brace))
{
self.bump(); // consume the doc comment
if self.eat(&token::Comma) || self.token == token::CloseDelim(token::Brace) {
err.emit();
} else {
return Err(err);