Skip to content

Commit 8e956e1

Browse files
authored
Fix when the help message is displayed
Only display the "remove this comma" suggestion when followed by an identifier
1 parent 4b32ddd commit 8e956e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ impl<'a> Parser<'a> {
767767
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
768768
} else {
769769
err.span_label(self.span, "expected identifier");
770-
if self.token == token::Comma {
771-
err.span_suggestion(self.span, "remove this comma", ",".into());
770+
if self.token == token::Comma && self.look_ahead(1, |t| *t.is_ident()) {
771+
err.span_suggestion(self.span, "remove this comma", "".into());
772772
}
773773
}
774774
err

0 commit comments

Comments
 (0)