@@ -121,27 +121,7 @@ impl<'a> Parser<'a> {
121
121
let ( qself, path) = self . parse_qpath ( PathStyle :: Type ) ?;
122
122
TyKind :: Path ( Some ( qself) , path)
123
123
} else if self . token . is_path_start ( ) {
124
- // Simple path
125
- let path = self . parse_path ( PathStyle :: Type ) ?;
126
- if self . eat ( & token:: Not ) {
127
- // Macro invocation in type position
128
- let args = self . parse_mac_args ( ) ?;
129
- let mac = Mac {
130
- path,
131
- args,
132
- prior_type_ascription : self . last_type_ascription ,
133
- } ;
134
- TyKind :: Mac ( mac)
135
- } else {
136
- // Just a type path or bound list (trait object type) starting with a trait.
137
- // `Type`
138
- // `Trait1 + Trait2 + 'a`
139
- if allow_plus && self . check_plus ( ) {
140
- self . parse_remaining_bounds ( Vec :: new ( ) , path, lo, true ) ?
141
- } else {
142
- TyKind :: Path ( None , path)
143
- }
144
- }
124
+ self . parse_path_start_ty ( lo, allow_plus) ?
145
125
} else if self . eat ( & token:: DotDotDot ) {
146
126
if allow_c_variadic {
147
127
TyKind :: CVarArgs
@@ -330,6 +310,31 @@ impl<'a> Parser<'a> {
330
310
Ok ( TyKind :: TraitObject ( bounds, TraitObjectSyntax :: Dyn ) )
331
311
}
332
312
313
+ /// Parses a type starting with a path.
314
+ ///
315
+ /// This can be:
316
+ /// 1. a type macro, `mac!(...)`,
317
+ /// 2. a bare trait object, `B0 + ... + Bn`,
318
+ /// 3. or a path, `path::to::MyType`.
319
+ fn parse_path_start_ty ( & mut self , lo : Span , allow_plus : bool ) -> PResult < ' a , TyKind > {
320
+ // Simple path
321
+ let path = self . parse_path ( PathStyle :: Type ) ?;
322
+ if self . eat ( & token:: Not ) {
323
+ // Macro invocation in type position
324
+ Ok ( TyKind :: Mac ( Mac {
325
+ path,
326
+ args : self . parse_mac_args ( ) ?,
327
+ prior_type_ascription : self . last_type_ascription ,
328
+ } ) )
329
+ } else if allow_plus && self . check_plus ( ) {
330
+ // `Trait1 + Trait2 + 'a`
331
+ self . parse_remaining_bounds ( Vec :: new ( ) , path, lo, true )
332
+ } else {
333
+ // Just a type path.
334
+ Ok ( TyKind :: Path ( None , path) )
335
+ }
336
+ }
337
+
333
338
pub ( super ) fn parse_generic_bounds ( & mut self ,
334
339
colon_span : Option < Span > ) -> PResult < ' a , GenericBounds > {
335
340
self . parse_generic_bounds_common ( true , colon_span)
0 commit comments