@@ -98,7 +98,6 @@ impl<'a> Parser<'a> {
98
98
// Function pointer type or bound list (trait object type) starting with a poly-trait.
99
99
// `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
100
100
// `for<'lt> Trait1<'lt> + Trait2 + 'a`
101
- let lo = self . token . span ;
102
101
let lifetime_defs = self . parse_late_bound_lifetime_defs ( ) ?;
103
102
if self . token_is_bare_fn_keyword ( ) {
104
103
self . parse_ty_bare_fn ( lifetime_defs) ?
@@ -108,10 +107,7 @@ impl<'a> Parser<'a> {
108
107
self . parse_remaining_bounds ( lifetime_defs, path, lo, parse_plus) ?
109
108
}
110
109
} else if self . eat_keyword ( kw:: Impl ) {
111
- // Always parse bounds greedily for better error recovery.
112
- let bounds = self . parse_generic_bounds ( None ) ?;
113
- impl_dyn_multi = bounds. len ( ) > 1 || self . prev_token_kind == PrevTokenKind :: Plus ;
114
- TyKind :: ImplTrait ( ast:: DUMMY_NODE_ID , bounds)
110
+ self . parse_impl_ty ( & mut impl_dyn_multi) ?
115
111
} else if self . check_keyword ( kw:: Dyn ) &&
116
112
( self . token . span . rust_2018 ( ) ||
117
113
self . look_ahead ( 1 , |t| t. can_begin_bound ( ) &&
@@ -312,6 +308,14 @@ impl<'a> Parser<'a> {
312
308
} ) ) )
313
309
}
314
310
311
+ /// Parses an `impl B0 + ... + Bn` type.
312
+ fn parse_impl_ty ( & mut self , impl_dyn_multi : & mut bool ) -> PResult < ' a , TyKind > {
313
+ // Always parse bounds greedily for better error recovery.
314
+ let bounds = self . parse_generic_bounds ( None ) ?;
315
+ * impl_dyn_multi = bounds. len ( ) > 1 || self . prev_token_kind == PrevTokenKind :: Plus ;
316
+ Ok ( TyKind :: ImplTrait ( ast:: DUMMY_NODE_ID , bounds) )
317
+ }
318
+
315
319
pub ( super ) fn parse_generic_bounds ( & mut self ,
316
320
colon_span : Option < Span > ) -> PResult < ' a , GenericBounds > {
317
321
self . parse_generic_bounds_common ( true , colon_span)
0 commit comments