about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorHirochika Matsumoto <hirochika.k.matsumoto@gmail.com>2023-05-16 14:53:05 +0900
committerHirochika Matsumoto <hirochika.k.matsumoto@gmail.com>2023-11-27 22:06:42 +0900
commit730d299354f7ef09d8e30609110fc499e0e22d71 (patch)
treeb4cdf853948757dffe6f792fbf5f40e780c6016d /compiler/rustc_parse/src/parser
parent61c3e4d56ecc77899095590d9fd03ffc39e9849e (diff)
downloadrust-730d299354f7ef09d8e30609110fc499e0e22d71.tar.gz
rust-730d299354f7ef09d8e30609110fc499e0e22d71.zip
Address review feedbacks
Also addressed merge conflicts upon rebasing.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 71db5609edc..391a4777bd9 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -571,6 +571,7 @@ impl<'a> Parser<'a> {
                         // integer literal (e.g. `1:42`), it's likely a range
                         // expression for Pythonistas and we can suggest so.
                         if self.prev_token.is_integer_lit()
+                            && self.may_recover()
                             && self.look_ahead(1, |token| token.is_integer_lit())
                         {
                             // FIXME(hkmatsumoto): Might be better to trigger
@@ -581,22 +582,22 @@ impl<'a> Parser<'a> {
                                 "..",
                                 Applicability::MaybeIncorrect,
                             );
-                        }
-
-                        // if next token is following a colon, it's likely a path
-                        // and we can suggest a path separator
-                        self.bump();
-                        if self.token.span.lo() == self.prev_token.span.hi() {
-                            err.span_suggestion_verbose(
-                                self.prev_token.span,
-                                "maybe write a path separator here",
-                                "::",
-                                Applicability::MaybeIncorrect,
-                            );
-                        }
-                        if self.sess.unstable_features.is_nightly_build() {
-                            // FIXME(Nilstrieb): Remove this again after a few months.
-                            err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
+                        } else {
+                            // if next token is following a colon, it's likely a path
+                            // and we can suggest a path separator
+                            self.bump();
+                            if self.token.span.lo() == self.prev_token.span.hi() {
+                                err.span_suggestion_verbose(
+                                    self.prev_token.span,
+                                    "maybe write a path separator here",
+                                    "::",
+                                    Applicability::MaybeIncorrect,
+                                );
+                            }
+                            if self.sess.unstable_features.is_nightly_build() {
+                                // FIXME(Nilstrieb): Remove this again after a few months.
+                                err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
+                            }
                         }
                     }