@@ -110,15 +110,6 @@ pub enum PathParsingMode {
110
110
LifetimeAndTypesWithColons ,
111
111
}
112
112
113
- /// How to parse a qualified path, whether to allow trailing parameters.
114
- #[ derive( Copy , Clone , PartialEq ) ]
115
- pub enum QPathParsingMode {
116
- /// No trailing parameters, e.g. `<T as Trait>::Item`
117
- NoParameters ,
118
- /// Optional parameters, e.g. `<T as Trait>::item::<'a, U>`
119
- MaybeParameters ,
120
- }
121
-
122
113
/// How to parse a bound, whether to allow bound modifiers such as `?`.
123
114
#[ derive( Copy , Clone , PartialEq ) ]
124
115
pub enum BoundParsingMode {
@@ -1360,7 +1351,7 @@ impl<'a> Parser<'a> {
1360
1351
} else if try!( self . eat_lt ( ) ) {
1361
1352
1362
1353
let ( qself, path) =
1363
- try!( self . parse_qualified_path ( QPathParsingMode :: NoParameters ) ) ;
1354
+ try!( self . parse_qualified_path ( NoTypesAllowed ) ) ;
1364
1355
1365
1356
TyPath ( Some ( qself) , path)
1366
1357
} else if self . check ( & token:: ModSep ) ||
@@ -1579,7 +1570,7 @@ impl<'a> Parser<'a> {
1579
1570
1580
1571
// QUALIFIED PATH `<TYPE [as TRAIT_REF]>::IDENT[::<PARAMS>]`
1581
1572
// Assumes that the leading `<` has been parsed already.
1582
- pub fn parse_qualified_path ( & mut self , mode : QPathParsingMode )
1573
+ pub fn parse_qualified_path ( & mut self , mode : PathParsingMode )
1583
1574
-> PResult < ( QSelf , ast:: Path ) > {
1584
1575
let self_type = try!( self . parse_ty_sum ( ) ) ;
1585
1576
let mut path = if try!( self . eat_keyword ( keywords:: As ) ) {
@@ -1600,29 +1591,18 @@ impl<'a> Parser<'a> {
1600
1591
try!( self . expect ( & token:: Gt ) ) ;
1601
1592
try!( self . expect ( & token:: ModSep ) ) ;
1602
1593
1603
- let item_name = try!( self . parse_ident ( ) ) ;
1604
- let parameters = match mode {
1605
- QPathParsingMode :: NoParameters => ast:: PathParameters :: none ( ) ,
1606
- QPathParsingMode :: MaybeParameters => {
1607
- if try!( self . eat ( & token:: ModSep ) ) {
1608
- try!( self . expect_lt ( ) ) ;
1609
- // Consumed `item::<`, go look for types
1610
- let ( lifetimes, types, bindings) =
1611
- try!( self . parse_generic_values_after_lt ( ) ) ;
1612
- ast:: AngleBracketedParameters ( ast:: AngleBracketedParameterData {
1613
- lifetimes : lifetimes,
1614
- types : OwnedSlice :: from_vec ( types) ,
1615
- bindings : OwnedSlice :: from_vec ( bindings) ,
1616
- } )
1617
- } else {
1618
- ast:: PathParameters :: none ( )
1619
- }
1594
+ let segments = match mode {
1595
+ LifetimeAndTypesWithoutColons => {
1596
+ try!( self . parse_path_segments_without_colons ( ) )
1597
+ }
1598
+ LifetimeAndTypesWithColons => {
1599
+ try!( self . parse_path_segments_with_colons ( ) )
1600
+ }
1601
+ NoTypesAllowed => {
1602
+ try!( self . parse_path_segments_without_types ( ) )
1620
1603
}
1621
1604
} ;
1622
- path. segments . push ( ast:: PathSegment {
1623
- identifier : item_name,
1624
- parameters : parameters
1625
- } ) ;
1605
+ path. segments . extend ( segments) ;
1626
1606
1627
1607
if path. segments . len ( ) == 1 {
1628
1608
path. span . lo = self . last_span . lo ;
@@ -2097,7 +2077,7 @@ impl<'a> Parser<'a> {
2097
2077
if try!( self . eat_lt ( ) ) {
2098
2078
2099
2079
let ( qself, path) =
2100
- try!( self . parse_qualified_path ( QPathParsingMode :: MaybeParameters ) ) ;
2080
+ try!( self . parse_qualified_path ( LifetimeAndTypesWithColons ) ) ;
2101
2081
2102
2082
return Ok ( self . mk_expr ( lo, hi, ExprPath ( Some ( qself) , path) ) ) ;
2103
2083
}
@@ -3177,7 +3157,7 @@ impl<'a> Parser<'a> {
3177
3157
let ( qself, path) = if try!( self . eat_lt ( ) ) {
3178
3158
// Parse a qualified path
3179
3159
let ( qself, path) =
3180
- try!( self . parse_qualified_path ( QPathParsingMode :: NoParameters ) ) ;
3160
+ try!( self . parse_qualified_path ( NoTypesAllowed ) ) ;
3181
3161
( Some ( qself) , path)
3182
3162
} else {
3183
3163
// Parse an unqualified path
@@ -3271,7 +3251,7 @@ impl<'a> Parser<'a> {
3271
3251
let ( qself, path) = if try!( self . eat_lt ( ) ) {
3272
3252
// Parse a qualified path
3273
3253
let ( qself, path) =
3274
- try!( self . parse_qualified_path ( QPathParsingMode :: NoParameters ) ) ;
3254
+ try!( self . parse_qualified_path ( NoTypesAllowed ) ) ;
3275
3255
( Some ( qself) , path)
3276
3256
} else {
3277
3257
// Parse an unqualified path
0 commit comments