From fadb86f25d4053289c612cbba6b92da793976c16 Mon Sep 17 00:00:00 2001 From: Maerten <39694331+lambtowolf@users.noreply.github.com> Date: Wed, 30 May 2018 09:16:18 +0200 Subject: [PATCH] Fix when the help message is displayed Only display the "remove this comma" suggestion when followed by an identifier --- src/libsyntax/parse/parser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1ed902e8861..d6916c1c344 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -776,8 +776,8 @@ fn expected_ident_found(&self) -> DiagnosticBuilder<'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