Skip to content

Commit aa4999e

Browse files
committed
parse_angle_arg: parse constraints first
1 parent abce488 commit aa4999e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/librustc_parse/parser/path.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,7 @@ impl<'a> Parser<'a> {
399399

400400
/// Parses a single argument in the angle arguments `<...>` of a path segment.
401401
fn parse_angle_arg(&mut self) -> PResult<'a, Option<AngleBracketedArg>> {
402-
let arg = if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
403-
// Parse lifetime argument.
404-
AngleBracketedArg::Arg(GenericArg::Lifetime(self.expect_lifetime()))
405-
} else if self.check_ident()
402+
let arg = if self.check_ident()
406403
&& self.look_ahead(1, |t| matches!(t.kind, token::Eq | token::Colon))
407404
{
408405
// Parse associated type constraint.
@@ -426,6 +423,9 @@ impl<'a> Parser<'a> {
426423

427424
let constraint = AssocTyConstraint { id: ast::DUMMY_NODE_ID, ident, kind, span };
428425
AngleBracketedArg::Constraint(constraint)
426+
} else if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
427+
// Parse lifetime argument.
428+
AngleBracketedArg::Arg(GenericArg::Lifetime(self.expect_lifetime()))
429429
} else if self.check_const_arg() {
430430
// Parse const argument.
431431
let expr = if let token::OpenDelim(token::Brace) = self.token.kind {

0 commit comments

Comments
 (0)