Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5279499rwr; Mon, 24 Apr 2023 01:25:45 -0700 (PDT) X-Google-Smtp-Source: AKy350bgDWzZmI+6myHWEhyQfbRct6S2bRM3hGOGsl1UOf5E3SM/w6gjnR03gVUF+V08ESmxhy1I X-Received: by 2002:a05:6a20:3ca5:b0:f0:2222:8b58 with SMTP id b37-20020a056a203ca500b000f022228b58mr17127203pzj.12.1682324745518; Mon, 24 Apr 2023 01:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682324745; cv=none; d=google.com; s=arc-20160816; b=ZJHueTW9e1MbUDsDeDg8kJRBr0HUsAlAdWAEk/hcZJtbV02S2H/7H1BC8FuK8HYyTX O1MfRq5MSlXua+eeEs7e3Bmqwct599fzMLsMJWmqRrE6CpdQ0p3JDOwSrf2zfctLb3eu /5UTsaWADlLGnT1oK1KO2be/sMO1sZmDZdg7q1NAJJiIcjl5nr1uW3PR7atp5say7/3i SMIjyGKelB9q6GOpHhlxhM7RDuK7ZxhdXrlRS/2ssj4jWYaRkjTqlPROfCwGJqFdp2vP iGCMYtTEt/kO6sZXV6tOOHHbL5vqYte6WbSFTMnudBylM2Ihz44QemCmiEYKwUurxNm4 p/1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:message-id:subject:cc:from:to:dkim-signature:date; bh=9tXLJw7aS2XfS2d3gc4JfQ1c+axPiaqoVKfXWCkw42E=; b=L6jaUCUKBfGOGQaoJlbso+fvmTRMUi9NhgROKHw8gR0OMUIVKazUaLCTjCcru1NuMA tmakOQplub/nW83kca5GpFn6LsptRbVAETOgN4IQ2OJfVBGTmiQxH61W39/62TRkSKcz UJxW3CJJZXmVFf/MGRzRoIur8iwH/OAG8oUVDX2QYYG+9LQhSP8SAnYi1WAX3fL8cmBJ qMmbZy3/gMvP9XRFoqPb/wclr2KMc5aY8IyME2AHCqfE3JNSljC72ChmaCe1r1TlY5RQ ph/Gi1sjSsaWjqiOa2mLE6MkUG1Z7oSk2kepvecgXh02GnSl1MyOTENtm04LP/hAZ2/E hXUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=bf4SNBhM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a656242000000b005144b3c3e50si10749138pgv.68.2023.04.24.01.25.30; Mon, 24 Apr 2023 01:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=bf4SNBhM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbjDXIL7 (ORCPT + 99 others); Mon, 24 Apr 2023 04:11:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231551AbjDXILs (ORCPT ); Mon, 24 Apr 2023 04:11:48 -0400 Received: from mail-0301.mail-europe.com (mail-0301.mail-europe.com [188.165.51.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38FA910E7; Mon, 24 Apr 2023 01:11:47 -0700 (PDT) Date: Mon, 24 Apr 2023 08:11:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1682323903; x=1682583103; bh=9tXLJw7aS2XfS2d3gc4JfQ1c+axPiaqoVKfXWCkw42E=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=bf4SNBhMwTguIdAncVzh5qLxV1ZYWi5GolZ7vhl4PHQALjDS4AaYfZPVsJxi3p4Xy J9c0TDW7wOHdvqGNedNTQfjXceAGYPKLW05jU0wRyPNiFDDJW5uDo1eVsOUag1aqkj dzDynwvOS/V1XjvKh9Wvz/1PjZksRH24dtFWDY1KvqhbNtAisuGuzEmhYvZrqCA53v 59BuMDz2nIa3f41puY8UTwzFHvaMTBrIHbfP4W6q71ha+k477z6NSu9tcTXK3Uie0C h8JsTD9qERL7wpGzDU7nSSHk8//0sM7gDHTiWgE4CT+VN4lF6+yTEj158C8QFJO6J1 fu/YtqWt9PCBw== To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= From: Benno Lossin Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Benno Lossin Subject: [PATCH 1/4] rust: macros: fix usage of `#[allow]` in `quote!` Message-ID: <20230424081112.99890-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using `quote!` as part of an expression that was not the last one in a function, the `#[allow(clippy::vec_init_then_push)]` attribute would be present on an expression, which is not allowed. This patch refactors that part of the macro to use a statement instead. Signed-off-by: Benno Lossin --- rust/macros/quote.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs index c8e08b3c1e4c..dddbb4e6f4cb 100644 --- a/rust/macros/quote.rs +++ b/rust/macros/quote.rs @@ -39,12 +39,14 @@ impl ToTokens for TokenStream { /// [`quote_spanned!`](https://docs.rs/quote/latest/quote/macro.quote_span= ned.html) macro from the /// `quote` crate but provides only just enough functionality needed by th= e current `macros` crate. macro_rules! quote_spanned { - ($span:expr =3D> $($tt:tt)*) =3D> { - #[allow(clippy::vec_init_then_push)] - { - let mut tokens =3D ::std::vec::Vec::new(); - let span =3D $span; - quote_spanned!(@proc tokens span $($tt)*); + ($span:expr =3D> $($tt:tt)*) =3D> {{ + let mut tokens; + #[allow(clippy::vec_init_then_push)] + { + tokens =3D ::std::vec::Vec::new(); + let span =3D $span; + quote_spanned!(@proc tokens span $($tt)*); + } ::proc_macro::TokenStream::from_iter(tokens) }}; (@proc $v:ident $span:ident) =3D> {}; base-commit: ea76e08f4d901a450619831a255e9e0a4c0ed162 -- 2.40.0