public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] parser: Fix parsing closure parameter
Date: Sun,  5 Mar 2023 11:42:20 +0000 (GMT)	[thread overview]
Message-ID: <20230305114220.35E213858D35@sourceware.org> (raw)

https://gcc.gnu.org/g:a4c851df0358389970ffe3ce1ad495954729fc5f

commit a4c851df0358389970ffe3ce1ad495954729fc5f
Author: goar5670 <mahadelr19@gmail.com>
Date:   Thu Mar 2 21:34:44 2023 +0300

    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>

Diff:
---
 gcc/rust/parse/rust-parse-impl.h                   | 2 +-
 gcc/testsuite/rust/compile/closure_no_type_anno.rs | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 46704111f37..9b2bea73c99 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 00000000000..beade7607f0
--- /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;
+}

                 reply	other threads:[~2023-03-05 11:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230305114220.35E213858D35@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).