File tree Expand file tree Collapse file tree 1 file changed +23
-15
lines changed
src/librustc_parse/parser Expand file tree Collapse file tree 1 file changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -71,21 +71,7 @@ impl<'a> Parser<'a> {
7171 debug ! ( "parse_qpath: (decrement) count={:?}" , self . unmatched_angle_bracket_count) ;
7272 }
7373
74- if self . token . kind == token:: Colon {
75- // <Bar as Baz<T>>:Qux
76- // ^
77- self . bump ( ) ;
78-
79- self . diagnostic ( )
80- . struct_span_err ( self . prev_span , "found single colon where type path was expected" )
81- . span_suggestion (
82- self . prev_span ,
83- "use double colon" ,
84- "::" . to_string ( ) ,
85- Applicability :: MachineApplicable ,
86- )
87- . emit ( ) ;
88- } else {
74+ if !self . recover_colon_before_qpath_proj ( ) {
8975 self . expect ( & token:: ModSep ) ?;
9076 }
9177
@@ -95,6 +81,28 @@ impl<'a> Parser<'a> {
9581 Ok ( ( qself, Path { segments : path. segments , span : lo. to ( self . prev_span ) } ) )
9682 }
9783
84+ fn recover_colon_before_qpath_proj ( & mut self ) -> bool {
85+ if self . token . kind != token:: Colon {
86+ return false ;
87+ }
88+
89+ // <Bar as Baz<T>>:Qux
90+ // ^
91+ self . bump ( ) ;
92+
93+ self . diagnostic ( )
94+ . struct_span_err ( self . prev_span , "found single colon where type path was expected" )
95+ . span_suggestion (
96+ self . prev_span ,
97+ "use double colon" ,
98+ "::" . to_string ( ) ,
99+ Applicability :: MachineApplicable ,
100+ )
101+ . emit ( ) ;
102+
103+ true
104+ }
105+
98106 /// Parses simple paths.
99107 ///
100108 /// `path = [::] segment+`
You can’t perform that action at this time.
0 commit comments