]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: parser: Fix parsing closure parameter
authorgoar5670 <mahadelr19@gmail.com>
Thu, 2 Mar 2023 18:34:44 +0000 (21:34 +0300)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:19:02 +0000 (18:19 +0100)
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>
gcc/rust/parse/rust-parse-impl.h
gcc/testsuite/rust/compile/closure_no_type_anno.rs [new file with mode: 0644]

index f7e3cf4b6b19ca61e6a61519b9ffaec5cea7405b..53067bbf91d17a12197a5fbe5888dd638f9febba 100644 (file)
@@ -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 (file)
index 0000000..beade76
--- /dev/null
@@ -0,0 +1,5 @@
+// { dg-additional-options "-fsyntax-only" }
+
+pub fn foo() {
+  let a = |_| 15;
+}