@@ -98,7 +98,6 @@ impl<'a> Parser<'a> {
9898 // Function pointer type or bound list (trait object type) starting with a poly-trait.
9999 // `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
100100 // `for<'lt> Trait1<'lt> + Trait2 + 'a`
101- let lo = self . token . span ;
102101 let lifetime_defs = self . parse_late_bound_lifetime_defs ( ) ?;
103102 if self . token_is_bare_fn_keyword ( ) {
104103 self . parse_ty_bare_fn ( lifetime_defs) ?
@@ -108,10 +107,7 @@ impl<'a> Parser<'a> {
108107 self . parse_remaining_bounds ( lifetime_defs, path, lo, parse_plus) ?
109108 }
110109 } 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) ?
115111 } else if self . check_keyword ( kw:: Dyn ) &&
116112 ( self . token . span . rust_2018 ( ) ||
117113 self . look_ahead ( 1 , |t| t. can_begin_bound ( ) &&
@@ -312,6 +308,14 @@ impl<'a> Parser<'a> {
312308 } ) ) )
313309 }
314310
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+
315319 pub ( super ) fn parse_generic_bounds ( & mut self ,
316320 colon_span : Option < Span > ) -> PResult < ' a , GenericBounds > {
317321 self . parse_generic_bounds_common ( true , colon_span)
0 commit comments