about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorSean Patrick Santos <SeanPatrickSantos@gmail.com>2015-05-07 01:52:38 -0600
committerSean Patrick Santos <SeanPatrickSantos@gmail.com>2015-05-07 01:57:54 -0600
commitefb3872a49df2d4ffe5bdc948d1d12637fa3ebd1 (patch)
tree27ad4a4ad7c1b3ea52e4139bb1bb0fbe4e2b1f5b /src/libsyntax/parse
parent6b3d66b04f9ade6b3a46db4eb188e7397b44117a (diff)
downloadrust-efb3872a49df2d4ffe5bdc948d1d12637fa3ebd1.tar.gz
rust-efb3872a49df2d4ffe5bdc948d1d12637fa3ebd1.zip
Fix use of UFCS syntax to call methods on associated types.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs50
1 files changed, 15 insertions, 35 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index a7b1beace51..a5a667ae5ce 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -110,15 +110,6 @@ pub enum PathParsingMode {
     LifetimeAndTypesWithColons,
 }
 
-/// How to parse a qualified path, whether to allow trailing parameters.
-#[derive(Copy, Clone, PartialEq)]
-pub enum QPathParsingMode {
-    /// No trailing parameters, e.g. `<T as Trait>::Item`
-    NoParameters,
-    /// Optional parameters, e.g. `<T as Trait>::item::<'a, U>`
-    MaybeParameters,
-}
-
 /// How to parse a bound, whether to allow bound modifiers such as `?`.
 #[derive(Copy, Clone, PartialEq)]
 pub enum BoundParsingMode {
@@ -1360,7 +1351,7 @@ impl<'a> Parser<'a> {
         } else if try!(self.eat_lt()) {
 
             let (qself, path) =
-                 try!(self.parse_qualified_path(QPathParsingMode::NoParameters));
+                 try!(self.parse_qualified_path(NoTypesAllowed));
 
             TyPath(Some(qself), path)
         } else if self.check(&token::ModSep) ||
@@ -1579,7 +1570,7 @@ impl<'a> Parser<'a> {
 
     // QUALIFIED PATH `<TYPE [as TRAIT_REF]>::IDENT[::<PARAMS>]`
     // Assumes that the leading `<` has been parsed already.
-    pub fn parse_qualified_path(&mut self, mode: QPathParsingMode)
+    pub fn parse_qualified_path(&mut self, mode: PathParsingMode)
                                 -> PResult<(QSelf, ast::Path)> {
         let self_type = try!(self.parse_ty_sum());
         let mut path = if try!(self.eat_keyword(keywords::As)) {
@@ -1600,29 +1591,18 @@ impl<'a> Parser<'a> {
         try!(self.expect(&token::Gt));
         try!(self.expect(&token::ModSep));
 
-        let item_name = try!(self.parse_ident());
-        let parameters = match mode {
-            QPathParsingMode::NoParameters => ast::PathParameters::none(),
-            QPathParsingMode::MaybeParameters => {
-                if try!(self.eat(&token::ModSep)) {
-                    try!(self.expect_lt());
-                    // Consumed `item::<`, go look for types
-                    let (lifetimes, types, bindings) =
-                        try!(self.parse_generic_values_after_lt());
-                    ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
-                        lifetimes: lifetimes,
-                        types: OwnedSlice::from_vec(types),
-                        bindings: OwnedSlice::from_vec(bindings),
-                    })
-                } else {
-                    ast::PathParameters::none()
-                }
+        let segments = match mode {
+            LifetimeAndTypesWithoutColons => {
+                try!(self.parse_path_segments_without_colons())
+            }
+            LifetimeAndTypesWithColons => {
+                try!(self.parse_path_segments_with_colons())
+            }
+            NoTypesAllowed => {
+                try!(self.parse_path_segments_without_types())
             }
         };
-        path.segments.push(ast::PathSegment {
-            identifier: item_name,
-            parameters: parameters
-        });
+        path.segments.extend(segments);
 
         if path.segments.len() == 1 {
             path.span.lo = self.last_span.lo;
@@ -2097,7 +2077,7 @@ impl<'a> Parser<'a> {
                 if try!(self.eat_lt()){
 
                     let (qself, path) =
-                        try!(self.parse_qualified_path(QPathParsingMode::MaybeParameters));
+                        try!(self.parse_qualified_path(LifetimeAndTypesWithColons));
 
                     return Ok(self.mk_expr(lo, hi, ExprPath(Some(qself), path)));
                 }
@@ -3177,7 +3157,7 @@ impl<'a> Parser<'a> {
             let (qself, path) = if try!(self.eat_lt()) {
                 // Parse a qualified path
                 let (qself, path) =
-                    try!(self.parse_qualified_path(QPathParsingMode::NoParameters));
+                    try!(self.parse_qualified_path(NoTypesAllowed));
                 (Some(qself), path)
             } else {
                 // Parse an unqualified path
@@ -3271,7 +3251,7 @@ impl<'a> Parser<'a> {
                     let (qself, path) = if try!(self.eat_lt()) {
                         // Parse a qualified path
                         let (qself, path) =
-                            try!(self.parse_qualified_path(QPathParsingMode::NoParameters));
+                            try!(self.parse_qualified_path(NoTypesAllowed));
                         (Some(qself), path)
                     } else {
                         // Parse an unqualified path