From 5287004aa4f9b0685197cc0c009237812fed7047 Mon Sep 17 00:00:00 2001 From: Shrey Sudhir Date: Fri, 2 Dec 2022 00:40:33 +1100 Subject: [PATCH] Apply automatic suggestions from code review Co-authored-by: Takayuki Maeda --- compiler/rustc_parse/src/parser/diagnostics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 6df9cfd3ff4..1e1e804c0d3 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -345,7 +345,7 @@ pub(super) fn expected_ident_found(&mut self) -> DiagnosticBuilder<'a, ErrorGuar match self.parse_generics() { Ok(generic) => { if let TokenKind::Ident(symbol, _) = maybe_keyword.kind { - let ident_name = symbol.to_string(); + let ident_name = symbol; // at this point, we've found something like // `fn id` // and current token should be Ident with the item name (i.e. the function name) @@ -355,9 +355,9 @@ pub(super) fn expected_ident_found(&mut self) -> DiagnosticBuilder<'a, ErrorGuar let Ok(snippet) = self.sess.source_map().span_to_snippet(generic.span) && let Ok(ident) = self.sess.source_map().span_to_snippet(self.token.span) { err.span_suggestion_verbose( - generic.span.to(self.token.span), + self.token.span.shrink_to_hi(), format!("place the generic parameter name after the {ident_name} name"), - format!(" {ident}{snippet}"), + snippet, Applicability::MachineApplicable, ); } else {