Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <benno.lossin@proton.me>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://lore.kernel.org/r/20250308110339.2997091-7-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Benno Lossin and committed by
Miguel Ojeda
c2ddbdbb 84837cf6

+6 -20
+6 -20
rust/pin-init/src/lib.rs
··· 676 676 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 677 677 $($fields:tt)* 678 678 }) => { 679 - $crate::__init_internal!( 680 - @this($($this)?), 681 - @typ($t $(::<$($generics),*>)?), 682 - @fields($($fields)*), 683 - @error(::core::convert::Infallible), 684 - @data(PinData, use_data), 685 - @has_data(HasPinData, __pin_data), 686 - @construct_closure(pin_init_from_closure), 687 - @munch_fields($($fields)*), 688 - ) 679 + $crate::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? { 680 + $($fields)* 681 + }? ::core::convert::Infallible) 689 682 }; 690 683 } 691 684 ··· 777 784 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 778 785 $($fields:tt)* 779 786 }) => { 780 - $crate::__init_internal!( 781 - @this($($this)?), 782 - @typ($t $(::<$($generics),*>)?), 783 - @fields($($fields)*), 784 - @error(::core::convert::Infallible), 785 - @data(InitData, /*no use_data*/), 786 - @has_data(HasInitData, __init_data), 787 - @construct_closure(init_from_closure), 788 - @munch_fields($($fields)*), 789 - ) 787 + $crate::try_init!($(&$this in)? $t $(::<$($generics),*>)? { 788 + $($fields)* 789 + }? ::core::convert::Infallible) 790 790 } 791 791 } 792 792