@@ -17,8 +17,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
17
17
use log:: { debug, trace} ;
18
18
use std:: mem;
19
19
20
- const TURBOFISH : & ' static str = "use the \" turbofish\" `::<...>` instead of `<...>` to specify \
21
- type arguments";
20
+ const TURBOFISH : & ' static str = "use `::<...>` instead of `<...>` to specify type arguments" ;
22
21
/// Creates a placeholder argument.
23
22
crate fn dummy_arg ( ident : Ident ) -> Param {
24
23
let pat = P ( Pat {
@@ -585,7 +584,7 @@ impl<'a> Parser<'a> {
585
584
) ;
586
585
587
586
let suggest = |err : & mut DiagnosticBuilder < ' _ > | {
588
- err. span_suggestion (
587
+ err. span_suggestion_verbose (
589
588
op_span. shrink_to_lo ( ) ,
590
589
TURBOFISH ,
591
590
"::" . to_string ( ) ,
@@ -647,29 +646,16 @@ impl<'a> Parser<'a> {
647
646
// We have high certainty that this was a bad turbofish at this point.
648
647
// `foo< bar >(`
649
648
suggest ( & mut err) ;
650
-
651
- let snapshot = self . clone ( ) ;
652
- self . bump ( ) ; // `(`
653
-
654
649
// Consume the fn call arguments.
655
- let modifiers = [
656
- ( token:: OpenDelim ( token:: Paren ) , 1 ) ,
657
- ( token:: CloseDelim ( token:: Paren ) , -1 ) ,
658
- ] ;
659
- self . consume_tts ( 1 , & modifiers[ ..] ) ;
660
-
661
- if self . token . kind == token:: Eof {
662
- // Not entirely sure now, but we bubble the error up with the
663
- // suggestion.
664
- mem:: replace ( self , snapshot) ;
665
- Err ( err)
666
- } else {
667
- // 99% certain that the suggestion is correct, continue parsing.
668
- err. emit ( ) ;
669
- // FIXME: actually check that the two expressions in the binop are
670
- // paths and resynthesize new fn call expression instead of using
671
- // `ExprKind::Err` placeholder.
672
- mk_err_expr ( self , lhs. span . to ( self . prev_span ) )
650
+ match self . consume_fn_args ( ) {
651
+ Err ( ( ) ) => Err ( err) ,
652
+ Ok ( ( ) ) => {
653
+ err. emit ( ) ;
654
+ // FIXME: actually check that the two expressions in the binop are
655
+ // paths and resynthesize new fn call expression instead of using
656
+ // `ExprKind::Err` placeholder.
657
+ mk_err_expr ( self , lhs. span . to ( self . prev_span ) )
658
+ }
673
659
}
674
660
} else {
675
661
// All we know is that this is `foo < bar >` and *nothing* else. Try to
@@ -687,6 +673,27 @@ impl<'a> Parser<'a> {
687
673
Ok ( None )
688
674
}
689
675
676
+ fn consume_fn_args ( & mut self ) -> Result < ( ) , ( ) > {
677
+ let snapshot = self . clone ( ) ;
678
+ self . bump ( ) ; // `(`
679
+
680
+ // Consume the fn call arguments.
681
+ let modifiers = [
682
+ ( token:: OpenDelim ( token:: Paren ) , 1 ) ,
683
+ ( token:: CloseDelim ( token:: Paren ) , -1 ) ,
684
+ ] ;
685
+ self . consume_tts ( 1 , & modifiers[ ..] ) ;
686
+
687
+ if self . token . kind == token:: Eof {
688
+ // Not entirely sure that what we consumed were fn arguments, rollback.
689
+ mem:: replace ( self , snapshot) ;
690
+ Err ( ( ) )
691
+ } else {
692
+ // 99% certain that the suggestion is correct, continue parsing.
693
+ Ok ( ( ) )
694
+ }
695
+ }
696
+
690
697
crate fn maybe_report_ambiguous_plus (
691
698
& mut self ,
692
699
allow_plus : bool ,
0 commit comments