Emit DocComment in bad location error but continue parsing struct fields

This commit is contained in:
Esteban Küber 2017-11-23 13:15:31 -08:00
parent df357b20be
commit 4e2d1b9466

View file

@ -5419,8 +5419,16 @@ impl<'a> Parser<'a> {
self.bump();
}
token::CloseDelim(token::Brace) => {}
token::DocComment(_) => return Err(self.span_fatal_err(self.span,
Error::UselessDocComment)),
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))
{
err.emit();
} else {
return Err(err);
}
}
_ => return Err(self.span_fatal_help(self.span,
&format!("expected `,`, or `}}`, found `{}`", self.this_token_to_string()),
"struct fields should be separated by commas")),