From: Arthur Cohen Date: Thu, 2 Feb 2023 14:32:17 +0000 (+0100) Subject: gccrs: parser: Fix parsing of closure param list X-Git-Tag: basepoints/gcc-14~151 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f5144d1c9638eee4499c45d6ee625ff670cbe69;p=thirdparty%2Fgcc.git gccrs: parser: Fix parsing of closure param list gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_closure_expr): Advance tokens properly when parsing closure param list. gcc/testsuite/ChangeLog: * rust/compile/closure_move_expr.rs: New test. --- diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 3610790815c2..4ceb978f7f44 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -7592,6 +7592,7 @@ Parser::parse_closure_expr (AST::AttrVec outer_attrs) case PIPE: // actually may have parameters lexer.skip_token (); + t = lexer.peek_token (); while (t->get_id () != PIPE) { @@ -7608,6 +7609,7 @@ Parser::parse_closure_expr (AST::AttrVec outer_attrs) if (lexer.peek_token ()->get_id () != COMMA) { + lexer.skip_token (); // not an error but means param list is done break; } diff --git a/gcc/testsuite/rust/compile/closure_move_expr.rs b/gcc/testsuite/rust/compile/closure_move_expr.rs new file mode 100644 index 000000000000..780c316e0af2 --- /dev/null +++ b/gcc/testsuite/rust/compile/closure_move_expr.rs @@ -0,0 +1,9 @@ +// { dg-additional-options "-fsyntax-only" } + +fn foo() { + move |l: u32, r: u32| l + r +} + +fn foo2() { + |l: u32, r: u32| l + r +}