@@ -399,8 +399,7 @@ impl<'a> Parser<'a> {
399
399
400
400
/// Parses a single argument in the angle arguments `<...>` of a path segment.
401
401
fn parse_angle_arg ( & mut self ) -> PResult < ' a , Option < AngleBracketedArg > > {
402
- let arg = if self . check_ident ( )
403
- && self . look_ahead ( 1 , |t| matches ! ( t. kind, token:: Eq | token:: Colon ) )
402
+ if self . check_ident ( ) && self . look_ahead ( 1 , |t| matches ! ( t. kind, token:: Eq | token:: Colon ) )
404
403
{
405
404
// Parse associated type constraint.
406
405
let lo = self . token . span ;
@@ -422,10 +421,18 @@ impl<'a> Parser<'a> {
422
421
}
423
422
424
423
let constraint = AssocTyConstraint { id : ast:: DUMMY_NODE_ID , ident, kind, span } ;
425
- AngleBracketedArg :: Constraint ( constraint)
426
- } else if self . check_lifetime ( ) && self . look_ahead ( 1 , |t| !t. is_like_plus ( ) ) {
424
+ Ok ( Some ( AngleBracketedArg :: Constraint ( constraint) ) )
425
+ } else {
426
+ Ok ( self . parse_generic_arg ( ) ?. map ( AngleBracketedArg :: Arg ) )
427
+ }
428
+ }
429
+
430
+ /// Parse a generic argument in a path segment.
431
+ /// This does not include constraints, e.g., `Item = u8`, which is handled in `parse_angle_arg`.
432
+ fn parse_generic_arg ( & mut self ) -> PResult < ' a , Option < GenericArg > > {
433
+ let arg = if self . check_lifetime ( ) && self . look_ahead ( 1 , |t| !t. is_like_plus ( ) ) {
427
434
// Parse lifetime argument.
428
- AngleBracketedArg :: Arg ( GenericArg :: Lifetime ( self . expect_lifetime ( ) ) )
435
+ GenericArg :: Lifetime ( self . expect_lifetime ( ) )
429
436
} else if self . check_const_arg ( ) {
430
437
// Parse const argument.
431
438
let expr = if let token:: OpenDelim ( token:: Brace ) = self . token . kind {
@@ -451,11 +458,10 @@ impl<'a> Parser<'a> {
451
458
} else {
452
459
self . parse_literal_maybe_minus ( ) ?
453
460
} ;
454
- let value = AnonConst { id : ast:: DUMMY_NODE_ID , value : expr } ;
455
- AngleBracketedArg :: Arg ( GenericArg :: Const ( value) )
461
+ GenericArg :: Const ( AnonConst { id : ast:: DUMMY_NODE_ID , value : expr } )
456
462
} else if self . check_type ( ) {
457
463
// Parse type argument.
458
- AngleBracketedArg :: Arg ( GenericArg :: Type ( self . parse_ty ( ) ?) )
464
+ GenericArg :: Type ( self . parse_ty ( ) ?)
459
465
} else {
460
466
return Ok ( None ) ;
461
467
} ;
0 commit comments