aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-10-27 15:57:30 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-10-27 16:08:20 +0100
commit7604b6430cf3472399e5f24b7d8478a8ff89b22b (patch)
treef7503c89dffd0fc84e1560525c5e219cefc79d78 /gcc
parent4c873251e79980a86da81df4d7180e757c472ce9 (diff)
downloadgcc-7604b6430cf3472399e5f24b7d8478a8ff89b22b.zip
gcc-7604b6430cf3472399e5f24b7d8478a8ff89b22b.tar.gz
gcc-7604b6430cf3472399e5f24b7d8478a8ff89b22b.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h5
-rw-r--r--gcc/testsuite/rust/compile/torture/traits18.rs8
2 files changed, 9 insertions, 4 deletions
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<ManagedTokenSource>::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<ManagedTokenSource>::parse_path_generic_args ()
lexer.skip_token ();
t = lexer.peek_token ();
- t2 = lexer.peek_token (1);
}
// try to parse types second
diff --git a/gcc/testsuite/rust/compile/torture/traits18.rs b/gcc/testsuite/rust/compile/torture/traits18.rs
new file mode 100644
index 0000000..77cc5c2
--- /dev/null
+++ b/gcc/testsuite/rust/compile/torture/traits18.rs
@@ -0,0 +1,8 @@
+trait Foo<'a> {}
+
+trait Bar {
+ // { dg-warning "unused name .Bar." "" { target *-*-* } .-1 }
+
+ type Item: for<'a> Foo<'a>;
+ // { dg-warning "unused name" "" { target *-*-* } .-1 }
+}