]> git.lizzy.rs Git - rust.git/commitdiff
parse_angle_arg: parse constraints first
authorMazdak Farrokhzad <twingoow@gmail.com>
Sun, 22 Mar 2020 04:01:38 +0000 (05:01 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Fri, 27 Mar 2020 06:39:14 +0000 (07:39 +0100)
src/librustc_parse/parser/path.rs

index 3e0fc3a5478d34ca3b1d72720be465f5a8c46d31..9018564252464c38b024e8363981b3b61f004c4d 100644 (file)
@@ -399,10 +399,7 @@ fn parse_angle_args(&mut self) -> PResult<'a, Vec<AngleBracketedArg>> {
 
     /// 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 @@ fn parse_angle_arg(&mut self) -> PResult<'a, Option<AngleBracketedArg>> {
 
             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 {