Skip to content

Commit f8badd1

Browse files
BennoLossinojeda
authored andcommitted
rust: init: make #[pin_data] compatible with conditional compilation of fields
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. Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent b3068ac commit f8badd1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rust/kernel/init/macros.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ macro_rules! __pin_data {
962962
where $($whr)*
963963
{
964964
$(
965+
$(#[$($p_attr)*])*
965966
$pvis unsafe fn $p_field<E>(
966967
self,
967968
slot: *mut $p_type,
@@ -971,6 +972,7 @@ macro_rules! __pin_data {
971972
}
972973
)*
973974
$(
975+
$(#[$($attr)*])*
974976
$fvis unsafe fn $field<E>(
975977
self,
976978
slot: *mut $type,

0 commit comments

Comments
 (0)