From 7604b6430cf3472399e5f24b7d8478a8ff89b22b Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 27 Oct 2021 15:57:30 +0100 Subject: Fix parser error for lifetime arguments The loop was eagerly trying to ensure that there was multiple lifetimes since the predicate assumed there will be a comma or delimiter for the arguments. This changes the loop to keep reading lifetimes untill we fail to parse a lifetime or hit the end of the arguments. Fixes #773 --- gcc/rust/parse/rust-parse-impl.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'gcc/rust/parse/rust-parse-impl.h') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 14e4e80..8bddfcd 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6239,9 +6239,7 @@ Parser::parse_path_generic_args () const_TokenPtr t = lexer.peek_token (); Location locus = t->get_locus (); - const_TokenPtr t2 = lexer.peek_token (1); - while (t->get_id () == LIFETIME - && (t2->get_id () == COMMA || !is_right_angle_tok (t2->get_id ()))) + while (!is_right_angle_tok (t->get_id ())) { AST::Lifetime lifetime = parse_lifetime (); if (lifetime.is_error ()) @@ -6261,7 +6259,6 @@ Parser::parse_path_generic_args () lexer.skip_token (); t = lexer.peek_token (); - t2 = lexer.peek_token (1); } // try to parse types second -- cgit v1.1