about summary refs log tree commit diff
path: root/src/librustc_parse
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-22 05:01:38 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-27 07:39:14 +0100
commitaa4999ec6963162c38b74a4d50857d1cf2bfbc26 (patch)
treeda856db2daf8072fe056cf8626564702f20a32a2 /src/librustc_parse
parentabce4881e0553aed7683ed2ade6827b9de9aedaf (diff)
parse_angle_arg: parse constraints first
Diffstat (limited to 'src/librustc_parse')
-rw-r--r--src/librustc_parse/parser/path.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/librustc_parse/parser/path.rs b/src/librustc_parse/parser/path.rs
index 3e0fc3a5478..90185642524 100644
--- a/src/librustc_parse/parser/path.rs
+++ b/src/librustc_parse/parser/path.rs
@@ -399,10 +399,7 @@ impl<'a> Parser<'a> {
 
     /// Parses a single argument in the angle arguments `<...>` of a path segment.
     fn parse_angle_arg(&mut self) -> PResult<'a, Option<AngleBracketedArg>> {
-        let arg = if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
-            // Parse lifetime argument.
-            AngleBracketedArg::Arg(GenericArg::Lifetime(self.expect_lifetime()))
-        } else if self.check_ident()
+        let arg = if self.check_ident()
             && self.look_ahead(1, |t| matches!(t.kind, token::Eq | token::Colon))
         {
             // Parse associated type constraint.
@@ -426,6 +423,9 @@ impl<'a> Parser<'a> {
 
             let constraint = AssocTyConstraint { id: ast::DUMMY_NODE_ID, ident, kind, span };
             AngleBracketedArg::Constraint(constraint)
+        } else if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
+            // Parse lifetime argument.
+            AngleBracketedArg::Arg(GenericArg::Lifetime(self.expect_lifetime()))
         } else if self.check_const_arg() {
             // Parse const argument.
             let expr = if let token::OpenDelim(token::Brace) = self.token.kind {