From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 35E213858D35; Sun, 5 Mar 2023 11:42:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35E213858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678016540; bh=7WW/WcaJs285/59OX/CggBJqszcPBEuYObeDxfyVhvk=; h=From:To:Subject:Date:From; b=lpWiDdMjJfOVn7JMTkZwG31wnLHXwDN4Dp7OgBH75cRgnLMqqS+Ozt6sAVXDz/bl0 X8d5cLfz6Oza+ijc+B6Xk2PvRE3O0EtAh39mWOhPXGsD2M578/v/UwIt23MO3UIoVP cLy2zSAxJtxesNBSAGFX2VI7vUfjXL/HEIrDB4/c= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] parser: Fix parsing closure parameter X-Act-Checkin: gcc X-Git-Author: goar5670 X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 26b19976c898dd08f7234dc179ad57085f974b1a X-Git-Newrev: a4c851df0358389970ffe3ce1ad495954729fc5f Message-Id: <20230305114220.35E213858D35@sourceware.org> Date: Sun, 5 Mar 2023 11:42:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a4c851df0358389970ffe3ce1ad495954729fc5f commit a4c851df0358389970ffe3ce1ad495954729fc5f Author: goar5670 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 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::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 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; +}