From patchwork Wed Apr 5 14:03:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 1765450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=LGRYiOIV; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ps67r2HpFz1yZj for ; Thu, 6 Apr 2023 00:14:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BCC93832174 for ; Wed, 5 Apr 2023 14:11:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id DBB493853821 for ; Wed, 5 Apr 2023 14:05:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBB493853821 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42a.google.com with SMTP id r29so36306579wra.13 for ; Wed, 05 Apr 2023 07:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703551; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=WjHsg0/yMP9qY8d1KkNefjEqBT8kG3AOgrofVA59VIE=; b=LGRYiOIVI7ePlGlY/JAVfxWcr/XkxDgdDJxRxJDcWzlo+cKCVAw3KhQa9pyN6ghA7s fqj4wJx2ldosKlEHhP1Hmxa5L5/LCHpCcG5I95V8/uZX5aARfrPX3lIQRh8v6zFb7zSP o8RMIoSKaJ2E/sGvE/TyBmtiWfvVYDGajcH2S+fOGNCLppYI+XOLyT/JFkM+N5M0aHnR oB53dB7/njzvNoff9yZjK+9hDqgttWOiUhgNmyqwERv/c8T8hjt/Nb9G0vE/5AvVUdlc GVphRKMWbO9Cvn36K+fHId3AEqHj6U3V6VCHacik2gPQzsGyp/D+ll5qWTA1rRqsO66K QO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703551; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WjHsg0/yMP9qY8d1KkNefjEqBT8kG3AOgrofVA59VIE=; b=ZDIMqRR4a0hyZarqZpqk2n13xo+59AAiypwwOhpWT5bqFBicD644pyfm13aaCl5vK1 vaU6V3w2IJCAvi1Bx/AkCMKtr02/MQPDs5oJeceMmmRhFFhzpaH8WP7ZzvJpib5pwL8x H82XXfxHdLbmijSAko8CFUenj3b5e15/daD31qeT4LOLyQRTBfFQD2Ab0SwGUNyRTMF8 Wa19Z+nHvb2Y4g5RiEqpBdkLcm81qW3H+3nji6IPCGgDBAB72bP6N1Ng8m61SKnaZ9Va z142WWuspCDSCgBKRdYrh+6PD91E9v70aFihWSeZtPPLPCBAFlDhHEPgbXtQf2K1k8qM mdqw== X-Gm-Message-State: AAQBX9e7jyd21Rc+kot1xPpyNz24HrOO0pQmM+5N6fqoz0IsSarBv1fO 7Gwneq3O9Ega9gpv/KqHo2uhaCvmVli+22czOw== X-Google-Smtp-Source: AKy350a2prYfBr9IdlJxxbo7o4LFwDyd5AogXttN+i8C/TU0S3GkNS+83aqoklXYBnluhzABk5200A== X-Received: by 2002:adf:fa0c:0:b0:2ce:da65:1e1d with SMTP id m12-20020adffa0c000000b002ceda651e1dmr2153204wrr.24.1680703551070; Wed, 05 Apr 2023 07:05:51 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:05:50 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [committed 32/88] gccrs: parser: Fix parsing of closure param list Date: Wed, 5 Apr 2023 16:03:16 +0200 Message-Id: <20230405140411.3016563-33-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com> References: <20230405140411.3016563-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Arthur Cohen gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_closure_expr): Advance tokens properly when parsing closure param list. gcc/testsuite/ChangeLog: * rust/compile/closure_move_expr.rs: New test. --- gcc/rust/parse/rust-parse-impl.h | 2 ++ gcc/testsuite/rust/compile/closure_move_expr.rs | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/rust/compile/closure_move_expr.rs diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 3610790815c..4ceb978f7f4 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -7592,6 +7592,7 @@ Parser::parse_closure_expr (AST::AttrVec outer_attrs) case PIPE: // actually may have parameters lexer.skip_token (); + t = lexer.peek_token (); while (t->get_id () != PIPE) { @@ -7608,6 +7609,7 @@ Parser::parse_closure_expr (AST::AttrVec outer_attrs) if (lexer.peek_token ()->get_id () != COMMA) { + lexer.skip_token (); // not an error but means param list is done break; } diff --git a/gcc/testsuite/rust/compile/closure_move_expr.rs b/gcc/testsuite/rust/compile/closure_move_expr.rs new file mode 100644 index 00000000000..780c316e0af --- /dev/null +++ b/gcc/testsuite/rust/compile/closure_move_expr.rs @@ -0,0 +1,9 @@ +// { dg-additional-options "-fsyntax-only" } + +fn foo() { + move |l: u32, r: u32| l + r +} + +fn foo2() { + |l: u32, r: u32| l + r +}