@@ -399,8 +399,7 @@ impl<'a> Parser<'a> {
399399
400400 /// Parses a single argument in the angle arguments `<...>` of a path segment.
401401 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 ) )
404403 {
405404 // Parse associated type constraint.
406405 let lo = self . token . span ;
@@ -422,10 +421,18 @@ impl<'a> Parser<'a> {
422421 }
423422
424423 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 ( ) ) {
427434 // Parse lifetime argument.
428- AngleBracketedArg :: Arg ( GenericArg :: Lifetime ( self . expect_lifetime ( ) ) )
435+ GenericArg :: Lifetime ( self . expect_lifetime ( ) )
429436 } else if self . check_const_arg ( ) {
430437 // Parse const argument.
431438 let expr = if let token:: OpenDelim ( token:: Brace ) = self . token . kind {
@@ -451,11 +458,10 @@ impl<'a> Parser<'a> {
451458 } else {
452459 self . parse_literal_maybe_minus ( ) ?
453460 } ;
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 } )
456462 } else if self . check_type ( ) {
457463 // Parse type argument.
458- AngleBracketedArg :: Arg ( GenericArg :: Type ( self . parse_ty ( ) ?) )
464+ GenericArg :: Type ( self . parse_ty ( ) ?)
459465 } else {
460466 return Ok ( None ) ;
461467 } ;
0 commit comments