From nobody Tue Feb 10 07:57:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0EAC41513 for ; Sat, 29 Jul 2023 09:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbjG2JKE (ORCPT ); Sat, 29 Jul 2023 05:10:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231547AbjG2JJu (ORCPT ); Sat, 29 Jul 2023 05:09:50 -0400 Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 738A849EA for ; Sat, 29 Jul 2023 02:09:39 -0700 (PDT) Date: Sat, 29 Jul 2023 09:09:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1690621777; x=1690880977; bh=uCozY+Pcnawd0I1oW4pKqllFOri6l5nBR5qs/jiAoEo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=lKDPxnyFMYP6lsDUaojZFrgdIpXQuFcXehhvbFGFwtYfMVJJdCfW5fjrEI5WujI0f nWcuxjcz/5W2zriu2QFzV9LNl6aFYV+VGS2Kyu5UYjZ/r7myg3R69jwdzH8wTFSL3/ 5fcT5TAOiTzMpDobLg6KARjQhq2qOwiVuQ6u7jxTH5AzNIojixXcrQ/1rJSYgY1nf3 5ofLheTX0lz8SKwNMg4RUlc4vSx5LA1a0xZSgJ4cPdX0KRe7HFo2iZR3usR3ekeVnr +ztylJks1+CpoQFuiAAa7fnnQ0A0bZuFdmagIM5FTjPCvHlTjbJIq58ECc9rY0WUfS DYWrqz2d2kfcA== To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor From: Benno Lossin Cc: Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/13] rust: init: make `#[pin_data]` compatible with conditional compilation of fields Message-ID: <20230729090838.225225-3-benno.lossin@proton.me> In-Reply-To: <20230729090838.225225-1-benno.lossin@proton.me> References: <20230729090838.225225-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch allows one to write ``` #[pin_data] pub struct Foo { #[cfg(CONFIG_BAR)] a: Bar, #[cfg(not(CONFIG_BAR))] a: Baz, } ``` Before, this would result in a compile error, because `#[pin_data]` would generate two functions named `a` for both fields unconditionally. Signed-off-by: Benno Lossin Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Reviewed-by: Martin Rodriguez Reboredo --- rust/kernel/init/macros.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/kernel/init/macros.rs b/rust/kernel/init/macros.rs index fbaebd34f218..9182fdf99e7e 100644 --- a/rust/kernel/init/macros.rs +++ b/rust/kernel/init/macros.rs @@ -962,6 +962,7 @@ impl<$($impl_generics)*> $pin_data<$($ty_generics)*> where $($whr)* { $( + $(#[$($p_attr)*])* $pvis unsafe fn $p_field( self, slot: *mut $p_type, @@ -971,6 +972,7 @@ impl<$($impl_generics)*> $pin_data<$($ty_generics)*> } )* $( + $(#[$($attr)*])* $fvis unsafe fn $field( self, slot: *mut $type, --=20 2.41.0