@@ -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
0 commit comments