Fix when the help message is displayed

Only display the "remove this comma" suggestion when followed by an identifier
This commit is contained in:
Maerten 2018-05-30 09:16:18 +02:00 committed by Pietro Albini
parent 6c962e3ec4
commit fadb86f25d
No known key found for this signature in database
GPG Key ID: E8C1042DD1624519
1 changed files with 2 additions and 2 deletions

View File

@ -776,8 +776,8 @@ impl<'a> Parser<'a> {
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
} else {
err.span_label(self.span, "expected identifier");
if self.token == token::Comma {
err.span_suggestion(self.span, "remove this comma", ",".into());
if self.token == token::Comma && self.look_ahead(1, |t| *t.is_ident()) {
err.span_suggestion(self.span, "remove this comma", "".into());
}
}
err