aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorgoar5670 <mahadelr19@gmail.com>2023-03-02 21:34:44 +0300
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:19:02 +0100
commit24ce9baa6d9460752174db5577a751ea1964ad04 (patch)
tree113e44e65a3d9ebfd707cfb629768276503c0124 /gcc
parente6ff2bcc3a6107ecbef6e744c42f5e9b1b007dbe (diff)
downloadgcc-24ce9baa6d9460752174db5577a751ea1964ad04.zip
gcc-24ce9baa6d9460752174db5577a751ea1964ad04.tar.gz
gcc-24ce9baa6d9460752174db5577a751ea1964ad04.tar.bz2
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 <mahadelr19@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h2
-rw-r--r--gcc/testsuite/rust/compile/closure_no_type_anno.rs5
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index f7e3cf4b..53067bb 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -9055,7 +9055,7 @@ Parser<ManagedTokenSource>::parse_closure_param ()
AST::AttrVec outer_attrs = parse_outer_attributes ();
// parse pattern (which is required)
- std::unique_ptr<AST::Pattern> pattern = parse_pattern ();
+ std::unique_ptr<AST::Pattern> 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 0000000..beade76
--- /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;
+}