From: Benno Lossin Date: Sat, 8 Mar 2025 11:04:25 +0000 (+0000) Subject: rust: pin-init: call `try_[pin_]init!` from `[pin_]init!` instead of `__init_internal!` X-Git-Tag: v6.15-rc1~93^2~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2ddbdbb8a66f43f881c5fe1b8cd615b6dce5c40;p=thirdparty%2Flinux.git rust: pin-init: call `try_[pin_]init!` from `[pin_]init!` instead of `__init_internal!` The `[pin_]init!` macros have the same behavior as the `try_[pin_]init!` macros, except that they set the error type to `Infallible`. Instead of calling the primitive `__init_internal!` with the correct parameters, the same can thus be achieved by calling `try_[pin_]init!`. Since this makes it more clear what their behavior is, simplify the implementations of `[pin_]init!`. Signed-off-by: Benno Lossin Reviewed-by: Fiona Behrens Reviewed-by: Andreas Hindborg Tested-by: Andreas Hindborg Link: https://lore.kernel.org/r/20250308110339.2997091-7-benno.lossin@proton.me Signed-off-by: Miguel Ojeda --- diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs index fd9e36077e6ed..4df5216b80d76 100644 --- a/rust/pin-init/src/lib.rs +++ b/rust/pin-init/src/lib.rs @@ -676,16 +676,9 @@ macro_rules! pin_init { ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { $($fields:tt)* }) => { - $crate::__init_internal!( - @this($($this)?), - @typ($t $(::<$($generics),*>)?), - @fields($($fields)*), - @error(::core::convert::Infallible), - @data(PinData, use_data), - @has_data(HasPinData, __pin_data), - @construct_closure(pin_init_from_closure), - @munch_fields($($fields)*), - ) + $crate::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? { + $($fields)* + }? ::core::convert::Infallible) }; } @@ -784,16 +777,9 @@ macro_rules! init { ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { $($fields:tt)* }) => { - $crate::__init_internal!( - @this($($this)?), - @typ($t $(::<$($generics),*>)?), - @fields($($fields)*), - @error(::core::convert::Infallible), - @data(InitData, /*no use_data*/), - @has_data(HasInitData, __init_data), - @construct_closure(init_from_closure), - @munch_fields($($fields)*), - ) + $crate::try_init!($(&$this in)? $t $(::<$($generics),*>)? { + $($fields)* + }? ::core::convert::Infallible) } }