@@ -571,6 +571,7 @@ impl<'a> Parser<'a> {
571571 // integer literal (e.g. `1:42`), it's likely a range
572572 // expression for Pythonistas and we can suggest so.
573573 if self . prev_token . is_integer_lit ( )
574+ && self . may_recover ( )
574575 && self . look_ahead ( 1 , |token| token. is_integer_lit ( ) )
575576 {
576577 // FIXME(hkmatsumoto): Might be better to trigger
@@ -581,22 +582,22 @@ impl<'a> Parser<'a> {
581582 ".." ,
582583 Applicability :: MaybeIncorrect ,
583584 ) ;
584- }
585-
586- // if next token is following a colon, it's likely a path
587- // and we can suggest a path separator
588- self . bump ( ) ;
589- if self . token . span . lo ( ) == self . prev_token . span . hi ( ) {
590- err . span_suggestion_verbose (
591- self . prev_token . span ,
592- "maybe write a path separator here ",
593- "::" ,
594- Applicability :: MaybeIncorrect ,
595- ) ;
596- }
597- if self . sess . unstable_features . is_nightly_build ( ) {
598- // FIXME(Nilstrieb): Remove this again after a few months.
599- err . note ( "type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>" ) ;
585+ } else {
586+ // if next token is following a colon, it's likely a path
587+ // and we can suggest a path separator
588+ self . bump ( ) ;
589+ if self . token . span . lo ( ) == self . prev_token . span . hi ( ) {
590+ err . span_suggestion_verbose (
591+ self . prev_token . span ,
592+ "maybe write a path separator here" ,
593+ ":: ",
594+ Applicability :: MaybeIncorrect ,
595+ ) ;
596+ }
597+ if self . sess . unstable_features . is_nightly_build ( ) {
598+ // FIXME(Nilstrieb): Remove this again after a few months.
599+ err . note ( "type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>" ) ;
600+ }
600601 }
601602 }
602603
0 commit comments