@@ -112,13 +112,6 @@ pub enum PathParsingMode {
112112 LifetimeAndTypesAndBounds ,
113113}
114114
115- /// A pair of a path segment and group of type parameter bounds. (See `ast.rs`
116- /// for the definition of a path segment.)
117- struct PathSegmentAndBoundSet {
118- segment : ast:: PathSegment ,
119- bound_set : Option < OwnedSlice < TyParamBound > > ,
120- }
121-
122115/// A path paired with optional type bounds.
123116pub struct PathAndBounds {
124117 path : ast:: Path ,
@@ -1515,24 +1508,14 @@ impl<'a> Parser<'a> {
15151508 // First, parse an identifier.
15161509 let identifier = self . parse_ident ( ) ;
15171510
1518- // Next, parse a colon and bounded type parameters, if applicable.
1519- let bound_set = if mode == LifetimeAndTypesAndBounds {
1520- self . parse_optional_ty_param_bounds ( )
1521- } else {
1522- None
1523- } ;
1524-
15251511 // Parse the '::' before type parameters if it's required. If
15261512 // it is required and wasn't present, then we're done.
15271513 if mode == LifetimeAndTypesWithColons &&
15281514 !self . eat ( & token:: MOD_SEP ) {
1529- segments. push ( PathSegmentAndBoundSet {
1530- segment : ast:: PathSegment {
1531- identifier : identifier,
1532- lifetimes : Vec :: new ( ) ,
1533- types : OwnedSlice :: empty ( ) ,
1534- } ,
1535- bound_set : bound_set
1515+ segments. push ( ast:: PathSegment {
1516+ identifier : identifier,
1517+ lifetimes : Vec :: new ( ) ,
1518+ types : OwnedSlice :: empty ( ) ,
15361519 } ) ;
15371520 break
15381521 }
@@ -1549,13 +1532,10 @@ impl<'a> Parser<'a> {
15491532 } ;
15501533
15511534 // Assemble and push the result.
1552- segments. push ( PathSegmentAndBoundSet {
1553- segment : ast:: PathSegment {
1554- identifier : identifier,
1555- lifetimes : lifetimes,
1556- types : types,
1557- } ,
1558- bound_set : bound_set
1535+ segments. push ( ast:: PathSegment {
1536+ identifier : identifier,
1537+ lifetimes : lifetimes,
1538+ types : types,
15591539 } ) ;
15601540
15611541 // We're done if we don't see a '::', unless the mode required
@@ -1568,42 +1548,25 @@ impl<'a> Parser<'a> {
15681548 }
15691549 }
15701550
1551+ // Next, parse a colon and bounded type parameters, if applicable.
1552+ let bounds = if mode == LifetimeAndTypesAndBounds {
1553+ self . parse_optional_ty_param_bounds ( )
1554+ } else {
1555+ None
1556+ } ;
1557+
15711558 // Assemble the span.
15721559 let span = mk_sp ( lo, self . last_span . hi ) ;
15731560
1574- // Assemble the path segments.
1575- let mut path_segments = Vec :: new ( ) ;
1576- let mut bounds = None ;
1577- let last_segment_index = segments. len ( ) - 1 ;
1578- for ( i, segment_and_bounds) in segments. move_iter ( ) . enumerate ( ) {
1579- let PathSegmentAndBoundSet {
1580- segment : segment,
1581- bound_set : bound_set
1582- } = segment_and_bounds;
1583- path_segments. push ( segment) ;
1584-
1585- if bound_set. is_some ( ) {
1586- if i != last_segment_index {
1587- self . span_err ( span,
1588- "type parameter bounds are allowed only \
1589- before the last segment in a path")
1590- }
1591-
1592- bounds = bound_set
1593- }
1594- }
1595-
15961561 // Assemble the result.
1597- let path_and_bounds = PathAndBounds {
1562+ PathAndBounds {
15981563 path : ast:: Path {
15991564 span : span,
16001565 global : is_global,
1601- segments : path_segments ,
1566+ segments : segments ,
16021567 } ,
16031568 bounds : bounds,
1604- } ;
1605-
1606- path_and_bounds
1569+ }
16071570 }
16081571
16091572 /// parses 0 or 1 lifetime
0 commit comments