Skip to content

Commit 7604b64

Browse files
committed
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
1 parent 4c87325 commit 7604b64

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

gcc/rust/parse/rust-parse-impl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6239,9 +6239,7 @@ Parser<ManagedTokenSource>::parse_path_generic_args ()
62396239

62406240
const_TokenPtr t = lexer.peek_token ();
62416241
Location locus = t->get_locus ();
6242-
const_TokenPtr t2 = lexer.peek_token (1);
6243-
while (t->get_id () == LIFETIME
6244-
&& (t2->get_id () == COMMA || !is_right_angle_tok (t2->get_id ())))
6242+
while (!is_right_angle_tok (t->get_id ()))
62456243
{
62466244
AST::Lifetime lifetime = parse_lifetime ();
62476245
if (lifetime.is_error ())
@@ -6261,7 +6259,6 @@ Parser<ManagedTokenSource>::parse_path_generic_args ()
62616259
lexer.skip_token ();
62626260

62636261
t = lexer.peek_token ();
6264-
t2 = lexer.peek_token (1);
62656262
}
62666263

62676264
// try to parse types second
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait Foo<'a> {}
2+
3+
trait Bar {
4+
// { dg-warning "unused name .Bar." "" { target *-*-* } .-1 }
5+
6+
type Item: for<'a> Foo<'a>;
7+
// { dg-warning "unused name" "" { target *-*-* } .-1 }
8+
}

0 commit comments

Comments
 (0)