@@ -305,8 +305,13 @@ impl<'a> Parser<'a> {
305
305
let removal_span = kw. span . with_hi ( self . token . span . lo ( ) ) ;
306
306
let path = self . parse_path ( PathStyle :: Type ) ?;
307
307
let parse_plus = allow_plus == AllowPlus :: Yes && self . check_plus ( ) ;
308
- let kind =
309
- self . parse_remaining_bounds_path ( lifetime_defs, path, lo, parse_plus) ?;
308
+ let kind = self . parse_remaining_bounds_path (
309
+ lifetime_defs,
310
+ path,
311
+ lo,
312
+ parse_plus,
313
+ false ,
314
+ ) ?;
310
315
let err = self . dcx ( ) . create_err ( errors:: TransposeDynOrImpl {
311
316
span : kw. span ,
312
317
kw : kw. name . as_str ( ) ,
@@ -333,7 +338,7 @@ impl<'a> Parser<'a> {
333
338
} else {
334
339
let path = self . parse_path ( PathStyle :: Type ) ?;
335
340
let parse_plus = allow_plus == AllowPlus :: Yes && self . check_plus ( ) ;
336
- self . parse_remaining_bounds_path ( lifetime_defs, path, lo, parse_plus) ?
341
+ self . parse_remaining_bounds_path ( lifetime_defs, path, lo, parse_plus, false ) ?
337
342
}
338
343
}
339
344
} else if self . eat_keyword ( exp ! ( Impl ) ) {
@@ -414,7 +419,7 @@ impl<'a> Parser<'a> {
414
419
match ty. kind {
415
420
// `(TY_BOUND_NOPAREN) + BOUND + ...`.
416
421
TyKind :: Path ( None , path) if maybe_bounds => {
417
- self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true )
422
+ self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true , true )
418
423
}
419
424
// For `('a) + …`, we know that `'a` in type position already lead to an error being
420
425
// emitted. To reduce output, let's indirectly suppress E0178 (bad `+` in type) and
@@ -495,12 +500,14 @@ impl<'a> Parser<'a> {
495
500
path : ast:: Path ,
496
501
lo : Span ,
497
502
parse_plus : bool ,
503
+ has_parens : bool ,
498
504
) -> PResult < ' a , TyKind > {
499
505
let poly_trait_ref = PolyTraitRef :: new (
500
506
generic_params,
501
507
path,
502
508
TraitBoundModifiers :: NONE ,
503
509
lo. to ( self . prev_token . span ) ,
510
+ has_parens,
504
511
) ;
505
512
let bounds = vec ! [ GenericBound :: Trait ( poly_trait_ref) ] ;
506
513
self . parse_remaining_bounds ( bounds, parse_plus)
@@ -832,7 +839,7 @@ impl<'a> Parser<'a> {
832
839
Ok ( TyKind :: MacCall ( P ( MacCall { path, args : self . parse_delim_args ( ) ? } ) ) )
833
840
} else if allow_plus == AllowPlus :: Yes && self . check_plus ( ) {
834
841
// `Trait1 + Trait2 + 'a`
835
- self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true )
842
+ self . parse_remaining_bounds_path ( ThinVec :: new ( ) , path, lo, true , false )
836
843
} else {
837
844
// Just a type path.
838
845
Ok ( TyKind :: Path ( None , path) )
@@ -1190,8 +1197,13 @@ impl<'a> Parser<'a> {
1190
1197
}
1191
1198
}
1192
1199
1193
- let poly_trait =
1194
- PolyTraitRef :: new ( lifetime_defs, path, modifiers, lo. to ( self . prev_token . span ) ) ;
1200
+ let poly_trait = PolyTraitRef :: new (
1201
+ lifetime_defs,
1202
+ path,
1203
+ modifiers,
1204
+ lo. to ( self . prev_token . span ) ,
1205
+ has_parens,
1206
+ ) ;
1195
1207
Ok ( GenericBound :: Trait ( poly_trait) )
1196
1208
}
1197
1209
0 commit comments