@@ -310,7 +310,7 @@ impl<'a> Parser<'a> {
310310 path,
311311 lo,
312312 parse_plus,
313- false ,
313+ ast :: Grouping :: None ,
314314 ) ?;
315315 let err = self . dcx ( ) . create_err ( errors:: TransposeDynOrImpl {
316316 span : kw. span ,
@@ -338,7 +338,13 @@ impl<'a> Parser<'a> {
338338 } else {
339339 let path = self . parse_path ( PathStyle :: Type ) ?;
340340 let parse_plus = allow_plus == AllowPlus :: Yes && self . check_plus ( ) ;
341- self . parse_remaining_bounds_path ( lifetime_defs, path, lo, parse_plus, false ) ?
341+ self . parse_remaining_bounds_path (
342+ lifetime_defs,
343+ path,
344+ lo,
345+ parse_plus,
346+ ast:: Grouping :: None ,
347+ ) ?
342348 }
343349 }
344350 } else if self . eat_keyword ( exp ! ( Impl ) ) {
@@ -418,9 +424,13 @@ impl<'a> Parser<'a> {
418424 let maybe_bounds = allow_plus == AllowPlus :: Yes && self . token . is_like_plus ( ) ;
419425 match ty. kind {
420426 // `(TY_BOUND_NOPAREN) + BOUND + ...`.
421- TyKind :: Path ( None , path) if maybe_bounds => {
422- self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true , true )
423- }
427+ TyKind :: Path ( None , path) if maybe_bounds => self . parse_remaining_bounds_path (
428+ ThinVec :: new ( ) ,
429+ path,
430+ lo,
431+ true ,
432+ ast:: Grouping :: Parenthesized ,
433+ ) ,
424434 // For `('a) + …`, we know that `'a` in type position already lead to an error being
425435 // emitted. To reduce output, let's indirectly suppress E0178 (bad `+` in type) and
426436 // other irrelevant consequential errors.
@@ -500,14 +510,14 @@ impl<'a> Parser<'a> {
500510 path : ast:: Path ,
501511 lo : Span ,
502512 parse_plus : bool ,
503- has_parens : bool ,
513+ grouping : ast :: Grouping ,
504514 ) -> PResult < ' a , TyKind > {
505515 let poly_trait_ref = PolyTraitRef :: new (
506516 generic_params,
507517 path,
508518 TraitBoundModifiers :: NONE ,
509519 lo. to ( self . prev_token . span ) ,
510- has_parens ,
520+ grouping ,
511521 ) ;
512522 let bounds = vec ! [ GenericBound :: Trait ( poly_trait_ref) ] ;
513523 self . parse_remaining_bounds ( bounds, parse_plus)
@@ -839,7 +849,7 @@ impl<'a> Parser<'a> {
839849 Ok ( TyKind :: MacCall ( P ( MacCall { path, args : self . parse_delim_args ( ) ? } ) ) )
840850 } else if allow_plus == AllowPlus :: Yes && self . check_plus ( ) {
841851 // `Trait1 + Trait2 + 'a`
842- self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true , false )
852+ self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true , ast :: Grouping :: None )
843853 } else {
844854 // Just a type path.
845855 Ok ( TyKind :: Path ( None , path) )
@@ -1197,12 +1207,13 @@ impl<'a> Parser<'a> {
11971207 }
11981208 }
11991209
1210+ let grouping = if has_parens { ast:: Grouping :: Parenthesized } else { ast:: Grouping :: None } ;
12001211 let poly_trait = PolyTraitRef :: new (
12011212 lifetime_defs,
12021213 path,
12031214 modifiers,
12041215 lo. to ( self . prev_token . span ) ,
1205- has_parens ,
1216+ grouping ,
12061217 ) ;
12071218 Ok ( GenericBound :: Trait ( poly_trait) )
12081219 }
0 commit comments