From 4e2d1b946696357d7a57dcc6dfd47c42f91c3c10 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Thu, 23 Nov 2017 13:15:31 -0800 Subject: Emit `DocComment` in bad location error but continue parsing struct fields --- src/libsyntax/parse/parser.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index be7e589f4ad..07b918da0d1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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")), -- cgit 1.4.1-3-g733a5