Skip to content

Commit fadb86f

Browse files
lambtowolfpietroalbini
authored andcommitted
Fix when the help message is displayed
Only display the "remove this comma" suggestion when followed by an identifier
1 parent 6c962e3 commit fadb86f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libsyntax/parse/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,8 @@ impl<'a> Parser<'a> {
776776
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
777777
} else {
778778
err.span_label(self.span, "expected identifier");
779-
if self.token == token::Comma {
780-
err.span_suggestion(self.span, "remove this comma", ",".into());
779+
if self.token == token::Comma && self.look_ahead(1, |t| *t.is_ident()) {
780+
err.span_suggestion(self.span, "remove this comma", "".into());
781781
}
782782
}
783783
err

0 commit comments

Comments
 (0)