give a helpful diagnostic even when the next struct field has an attribute
This commit is contained in:
@@ -1539,8 +1539,12 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
if self.token.is_ident() {
|
||||
// This is likely another field; emit the diagnostic and keep going
|
||||
if self.token.is_ident()
|
||||
|| (self.token.kind == TokenKind::Pound
|
||||
&& (self.look_ahead(1, |t| t == &token::OpenDelim(Delimiter::Bracket))))
|
||||
{
|
||||
// This is likely another field, TokenKind::Pound is used for `#[..]` attribute for next field,
|
||||
// emit the diagnostic and keep going
|
||||
err.span_suggestion(
|
||||
sp,
|
||||
"try adding a comma",
|
||||
|
||||
Reference in New Issue
Block a user