Skip to content

Commit b8e582e

Browse files
committed
Address review feedbacks
Also addressed merge conflicts upon rebasing.
1 parent c32ea0a commit b8e582e

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

compiler/rustc_parse/src/parser/stmt.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ impl<'a> Parser<'a> {
567567
// integer literal (e.g. `1:42`), it's likely a range
568568
// expression for Pythonistas and we can suggest so.
569569
if self.prev_token.is_integer_lit()
570+
&& self.may_recover()
570571
&& self.look_ahead(1, |token| token.is_integer_lit())
571572
{
572573
// FIXME(hkmatsumoto): Might be better to trigger
@@ -577,22 +578,22 @@ impl<'a> Parser<'a> {
577578
"..",
578579
Applicability::MaybeIncorrect,
579580
);
580-
}
581-
582-
// if next token is following a colon, it's likely a path
583-
// and we can suggest a path separator
584-
self.bump();
585-
if self.token.span.lo() == self.prev_token.span.hi() {
586-
err.span_suggestion_verbose(
587-
self.prev_token.span,
588-
"maybe write a path separator here",
589-
"::",
590-
Applicability::MaybeIncorrect,
591-
);
592-
}
593-
if self.sess.unstable_features.is_nightly_build() {
594-
// FIXME(Nilstrieb): Remove this again after a few months.
595-
err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
581+
} else {
582+
// if next token is following a colon, it's likely a path
583+
// and we can suggest a path separator
584+
self.bump();
585+
if self.token.span.lo() == self.prev_token.span.hi() {
586+
err.span_suggestion_verbose(
587+
self.prev_token.span,
588+
"maybe write a path separator here",
589+
"::",
590+
Applicability::MaybeIncorrect,
591+
);
592+
}
593+
if self.sess.unstable_features.is_nightly_build() {
594+
// FIXME(Nilstrieb): Remove this again after a few months.
595+
err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
596+
}
596597
}
597598
}
598599

tests/ui/suggestions/range-index-instead-of-colon.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ fn main() {
44
&[1, 2, 3][1:2];
55
//~^ ERROR: expected one of
66
//~| HELP: you might have meant to make a slice with range index
7-
//~| HELP: maybe write a path separator here
87
}

tests/ui/suggestions/range-index-instead-of-colon.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ error: expected one of `.`, `?`, `]`, or an operator, found `:`
44
LL | &[1, 2, 3][1:2];
55
| ^ expected one of `.`, `?`, `]`, or an operator
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
87
help: you might have meant to make a slice with range index
98
|
109
LL | &[1, 2, 3][1..2];
1110
| ~~
12-
help: maybe write a path separator here
13-
|
14-
LL | &[1, 2, 3][1::2];
15-
| ~~
1611

1712
error: aborting due to previous error
1813

0 commit comments

Comments
 (0)