@@ -110,15 +110,6 @@ pub enum PathParsingMode {
110110 LifetimeAndTypesWithColons ,
111111}
112112
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-
122113/// How to parse a bound, whether to allow bound modifiers such as `?`.
123114#[ derive( Copy , Clone , PartialEq ) ]
124115pub enum BoundParsingMode {
@@ -1360,7 +1351,7 @@ impl<'a> Parser<'a> {
13601351 } else if try!( self . eat_lt ( ) ) {
13611352
13621353 let ( qself, path) =
1363- try!( self . parse_qualified_path ( QPathParsingMode :: NoParameters ) ) ;
1354+ try!( self . parse_qualified_path ( NoTypesAllowed ) ) ;
13641355
13651356 TyPath ( Some ( qself) , path)
13661357 } else if self . check ( & token:: ModSep ) ||
@@ -1579,7 +1570,7 @@ impl<'a> Parser<'a> {
15791570
15801571 // QUALIFIED PATH `<TYPE [as TRAIT_REF]>::IDENT[::<PARAMS>]`
15811572 // 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 )
15831574 -> PResult < ( QSelf , ast:: Path ) > {
15841575 let self_type = try!( self . parse_ty_sum ( ) ) ;
15851576 let mut path = if try!( self . eat_keyword ( keywords:: As ) ) {
@@ -1600,29 +1591,18 @@ impl<'a> Parser<'a> {
16001591 try!( self . expect ( & token:: Gt ) ) ;
16011592 try!( self . expect ( & token:: ModSep ) ) ;
16021593
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 ( ) )
16201603 }
16211604 } ;
1622- path. segments . push ( ast:: PathSegment {
1623- identifier : item_name,
1624- parameters : parameters
1625- } ) ;
1605+ path. segments . extend ( segments) ;
16261606
16271607 if path. segments . len ( ) == 1 {
16281608 path. span . lo = self . last_span . lo ;
@@ -2097,7 +2077,7 @@ impl<'a> Parser<'a> {
20972077 if try!( self . eat_lt ( ) ) {
20982078
20992079 let ( qself, path) =
2100- try!( self . parse_qualified_path ( QPathParsingMode :: MaybeParameters ) ) ;
2080+ try!( self . parse_qualified_path ( LifetimeAndTypesWithColons ) ) ;
21012081
21022082 return Ok ( self . mk_expr ( lo, hi, ExprPath ( Some ( qself) , path) ) ) ;
21032083 }
@@ -3177,7 +3157,7 @@ impl<'a> Parser<'a> {
31773157 let ( qself, path) = if try!( self . eat_lt ( ) ) {
31783158 // Parse a qualified path
31793159 let ( qself, path) =
3180- try!( self . parse_qualified_path ( QPathParsingMode :: NoParameters ) ) ;
3160+ try!( self . parse_qualified_path ( NoTypesAllowed ) ) ;
31813161 ( Some ( qself) , path)
31823162 } else {
31833163 // Parse an unqualified path
@@ -3271,7 +3251,7 @@ impl<'a> Parser<'a> {
32713251 let ( qself, path) = if try!( self . eat_lt ( ) ) {
32723252 // Parse a qualified path
32733253 let ( qself, path) =
3274- try!( self . parse_qualified_path ( QPathParsingMode :: NoParameters ) ) ;
3254+ try!( self . parse_qualified_path ( NoTypesAllowed ) ) ;
32753255 ( Some ( qself) , path)
32763256 } else {
32773257 // Parse an unqualified path
0 commit comments