aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoar5670 <mahadelr19@gmail.com>2023-03-02 21:34:44 +0300
committerPhilip Herron <philip.herron@embecosm.com>2023-03-03 15:17:49 +0000
commita4c851df0358389970ffe3ce1ad495954729fc5f (patch)
tree9b048c37f4842c617f9e562a4bfebf116f4ab46e
parent26b19976c898dd08f7234dc179ad57085f974b1a (diff)
downloadgcc-a4c851df0358389970ffe3ce1ad495954729fc5f.zip
gcc-a4c851df0358389970ffe3ce1ad495954729fc5f.tar.gz
gcc-a4c851df0358389970ffe3ce1ad495954729fc5f.tar.bz2
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>
-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 4670411..9b2bea7 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;
+}