From: goar5670 Date: Thu, 2 Mar 2023 18:34:44 +0000 (+0300) Subject: gccrs: parser: Fix parsing closure parameter X-Git-Tag: basepoints/gcc-15~2809 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24ce9baa6d9460752174db5577a751ea1964ad04;p=thirdparty%2Fgcc.git gccrs: parser: Fix parsing closure parameter gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_closure_param): Replace parse_pattern with parse_pattern_no_alt. gcc/testsuite/ChangeLog: * rust/compile/closure_no_type_anno.rs: New test. Signed-off-by: Mahmoud Mohamed --- diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index f7e3cf4b6b19..53067bbf91d1 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -9055,7 +9055,7 @@ Parser::parse_closure_param () AST::AttrVec outer_attrs = parse_outer_attributes (); // parse pattern (which is required) - std::unique_ptr pattern = parse_pattern (); + std::unique_ptr pattern = parse_pattern_no_alt (); if (pattern == nullptr) { // not necessarily an error diff --git a/gcc/testsuite/rust/compile/closure_no_type_anno.rs b/gcc/testsuite/rust/compile/closure_no_type_anno.rs new file mode 100644 index 000000000000..beade7607f09 --- /dev/null +++ b/gcc/testsuite/rust/compile/closure_no_type_anno.rs @@ -0,0 +1,5 @@ +// { dg-additional-options "-fsyntax-only" } + +pub fn foo() { + let a = |_| 15; +}