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> {
71
71
debug ! ( "parse_qpath: (decrement) count={:?}" , self . unmatched_angle_bracket_count) ;
72
72
}
73
73
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 ( ) {
89
75
self . expect ( & token:: ModSep ) ?;
90
76
}
91
77
@@ -95,6 +81,28 @@ impl<'a> Parser<'a> {
95
81
Ok ( ( qself, Path { segments : path. segments , span : lo. to ( self . prev_span ) } ) )
96
82
}
97
83
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
+
98
106
/// Parses simple paths.
99
107
///
100
108
/// `path = [::] segment+`
You can’t perform that action at this time.
0 commit comments