about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorChristian Poveda <git@pvdrz.com>2022-05-31 16:28:05 -0500
committerChristian Poveda <git@pvdrz.com>2022-05-31 16:28:05 -0500
commite1d63d1d7c19c6d341b9baed971493eb3354117c (patch)
tree7576b80dbbfeee94e1f5b410516cf529fc5629ed /compiler/rustc_parse/src
parent9ce04e378338b35d51a18c298f9f82fb4dbf920d (diff)
downloadrust-e1d63d1d7c19c6d341b9baed971493eb3354117c.tar.gz
rust-e1d63d1d7c19c6d341b9baed971493eb3354117c.zip
migrate `check_for_for_in_in_typo` diagnostic
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index dea9681a9af..d6b981bdeef 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -325,6 +325,15 @@ struct IncorrectAwait {
     question_mark: &'static str,
 }
 
+#[derive(SessionDiagnostic)]
+#[error(slug = "parser-in-in-typo")]
+struct InInTypo {
+    #[primary_span]
+    span: Span,
+    #[suggestion(applicability = "machine-applicable")]
+    sugg_span: Span,
+}
+
 // SnapshotParser is used to create a snapshot of the parser
 // without causing duplicate errors being emitted when the `Parser`
 // is dropped.
@@ -1953,14 +1962,10 @@ impl<'a> Parser<'a> {
     pub(super) fn check_for_for_in_in_typo(&mut self, in_span: Span) {
         if self.eat_keyword(kw::In) {
             // a common typo: `for _ in in bar {}`
-            self.struct_span_err(self.prev_token.span, "expected iterable, found keyword `in`")
-                .span_suggestion_short(
-                    in_span.until(self.prev_token.span),
-                    "remove the duplicated `in`",
-                    String::new(),
-                    Applicability::MachineApplicable,
-                )
-                .emit();
+            self.sess.emit_err(InInTypo {
+                span: self.prev_token.span,
+                sugg_span: in_span.until(self.prev_token.span),
+            });
         }
     }