@@ -310,7 +310,7 @@ impl<'a> Parser<'a> {
310
310
path,
311
311
lo,
312
312
parse_plus,
313
- false ,
313
+ ast :: Grouping :: None ,
314
314
) ?;
315
315
let err = self . dcx ( ) . create_err ( errors:: TransposeDynOrImpl {
316
316
span : kw. span ,
@@ -338,7 +338,13 @@ impl<'a> Parser<'a> {
338
338
} else {
339
339
let path = self . parse_path ( PathStyle :: Type ) ?;
340
340
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
+ ) ?
342
348
}
343
349
}
344
350
} else if self . eat_keyword ( exp ! ( Impl ) ) {
@@ -418,9 +424,13 @@ impl<'a> Parser<'a> {
418
424
let maybe_bounds = allow_plus == AllowPlus :: Yes && self . token . is_like_plus ( ) ;
419
425
match ty. kind {
420
426
// `(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
+ ) ,
424
434
// For `('a) + …`, we know that `'a` in type position already lead to an error being
425
435
// emitted. To reduce output, let's indirectly suppress E0178 (bad `+` in type) and
426
436
// other irrelevant consequential errors.
@@ -500,14 +510,14 @@ impl<'a> Parser<'a> {
500
510
path : ast:: Path ,
501
511
lo : Span ,
502
512
parse_plus : bool ,
503
- has_parens : bool ,
513
+ grouping : ast :: Grouping ,
504
514
) -> PResult < ' a , TyKind > {
505
515
let poly_trait_ref = PolyTraitRef :: new (
506
516
generic_params,
507
517
path,
508
518
TraitBoundModifiers :: NONE ,
509
519
lo. to ( self . prev_token . span ) ,
510
- has_parens ,
520
+ grouping ,
511
521
) ;
512
522
let bounds = vec ! [ GenericBound :: Trait ( poly_trait_ref) ] ;
513
523
self . parse_remaining_bounds ( bounds, parse_plus)
@@ -839,7 +849,7 @@ impl<'a> Parser<'a> {
839
849
Ok ( TyKind :: MacCall ( P ( MacCall { path, args : self . parse_delim_args ( ) ? } ) ) )
840
850
} else if allow_plus == AllowPlus :: Yes && self . check_plus ( ) {
841
851
// `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 )
843
853
} else {
844
854
// Just a type path.
845
855
Ok ( TyKind :: Path ( None , path) )
@@ -1197,12 +1207,13 @@ impl<'a> Parser<'a> {
1197
1207
}
1198
1208
}
1199
1209
1210
+ let grouping = if has_parens { ast:: Grouping :: Parenthesized } else { ast:: Grouping :: None } ;
1200
1211
let poly_trait = PolyTraitRef :: new (
1201
1212
lifetime_defs,
1202
1213
path,
1203
1214
modifiers,
1204
1215
lo. to ( self . prev_token . span ) ,
1205
- has_parens ,
1216
+ grouping ,
1206
1217
) ;
1207
1218
Ok ( GenericBound :: Trait ( poly_trait) )
1208
1219
}
0 commit comments