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: 79678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp350614vqo; Wed, 5 Apr 2023 07:29:27 -0700 (PDT) X-Google-Smtp-Source: AKy350bJ+EZ8mOOvl3l4SXjKW8B8izBEz9uy+prO1vsn41nf3jix5TG4+N6myh67/Ri2m67ICm/j X-Received: by 2002:a17:906:4cda:b0:947:d9b1:89a3 with SMTP id q26-20020a1709064cda00b00947d9b189a3mr2549067ejt.27.1680704967369; Wed, 05 Apr 2023 07:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680704967; cv=none; d=google.com; s=arc-20160816; b=p56y0RCFavGSS3sS+OPE5z/F/gyhu1yPPZmJ+Y2YXhFlnfbhB6DYsjI+EV/yODH9Q3 2iObOTigI0rws3mMOko2+KQ1mCH9//L6xp8u9evFFTu+rkNpsTAouw3gjFgc1GM5Bxk/ wn0SRps0hbtLn2I5+8C3UWR4djnW1f3JWTxCXEmilFcByBUSh+knUFyDoI0B7N8ehoVR VdEugANugyF3Dab0VW387QV7/gKkg7D8gamAbW8WiBdY1UQYXfUuqsqR9GffO2Z+ZsBp Hs5nLHocnD2cJKVp+g7JR63taLFAcAAdIb1c/HnWxuwXXsjuqm8uOVPqb1QqFBlc0JM4 BfaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dmarc-filter :delivered-to; bh=WjHsg0/yMP9qY8d1KkNefjEqBT8kG3AOgrofVA59VIE=; b=kg5H+jJMtN7WStnm1vTCGrZIGCpjH+VZf5tsPhTxtR8R82QyttgzvfbwwXgBNsjUuQ klqE/uu4hoPLA9Lqs4Dp28B2LHEUZ1lfrOFj8d2lR+NFbtrbBwnYkK84hhGf1QsuOwXB 1g4DvfEU1YVvoCMmnurP2gJqabMjFU5nGN/ZNEi1Zf5hi+sLYqhf8T+btcHDAdk2mmfK eUdJ9uTUqBYIrPyWapjiPL7nc2Z/x7MMqVJ1vemHtEjGASNubIHLW2NnC55Wuu4Nxfib +U+KEmYAwIySqSKgsDdnyjoVFybzsL8jagGvYInJGMFnAXsVmke2RRo9Yc1kwraWmhTd 3SCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=LGRYiOIV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d21-20020a1709063ed500b00933f276be3fsi1498791ejj.656.2023.04.05.07.29.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=LGRYiOIV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50D3239266A9 for ; Wed, 5 Apr 2023 14:12:10 +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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762346892068323841?= X-GMAIL-MSGID: =?utf-8?q?1762346892068323841?= 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 +}