From aa4999ec6963162c38b74a4d50857d1cf2bfbc26 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 22 Mar 2020 05:01:38 +0100 Subject: [PATCH] parse_angle_arg: parse constraints first --- src/librustc_parse/parser/path.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_parse/parser/path.rs b/src/librustc_parse/parser/path.rs index 3e0fc3a5478d..901856425246 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> { - 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 {