From: Benno Lossin <benno.lossin@proton.me>
To: "Benno Lossin" <benno.lossin@proton.me>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>
Cc: Fiona Behrens <me@kloenk.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 06/22] rust: pin-init: call `try_[pin_]init!` from `[pin_]init!` instead of `__init_internal!`
Date: Sat, 08 Mar 2025 11:04:25 +0000 [thread overview]
Message-ID: <20250308110339.2997091-7-benno.lossin@proton.me> (raw)
In-Reply-To: <20250308110339.2997091-1-benno.lossin@proton.me>
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>
---
rust/pin-init/src/lib.rs | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
index fd9e36077e6e..4df5216b80d7 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)
}
}
--
2.47.2
next prev parent reply other threads:[~2025-03-08 11:04 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 11:03 [PATCH v2 00/22] make pin-init into a standalone crate Benno Lossin
2025-03-08 11:03 ` [PATCH v2 01/22] rust: init: disable doctests Benno Lossin
2025-03-08 11:04 ` [PATCH v2 02/22] rust: move pin-init API into its own directory Benno Lossin
2025-03-08 11:04 ` [PATCH v2 03/22] rust: add extensions to the pin-init crate and move relevant documentation there Benno Lossin
2025-03-18 11:32 ` Andreas Hindborg
2025-03-08 11:04 ` [PATCH v2 04/22] rust: pin-init: move proc-macro documentation into pin-init crate Benno Lossin
2025-03-18 11:33 ` Andreas Hindborg
2025-03-19 13:14 ` Miguel Ojeda
2025-03-08 11:04 ` [PATCH v2 05/22] rust: pin-init: change examples to the user-space version Benno Lossin
2025-03-08 11:04 ` Benno Lossin [this message]
2025-03-08 11:04 ` [PATCH v2 07/22] rust: pin-init: move the default error behavior of `try_[pin_]init` Benno Lossin
2025-03-08 11:04 ` [PATCH v2 08/22] rust: pin-init: move `InPlaceInit` and impls of `InPlaceWrite` into the kernel crate Benno Lossin
2025-03-18 11:37 ` Andreas Hindborg
2025-03-08 11:04 ` [PATCH v2 09/22] rust: pin-init: move impl `Zeroable` for `Opaque` and `Option<KBox<T>>` " Benno Lossin
2025-03-13 11:16 ` Fiona Behrens
2025-03-08 11:04 ` [PATCH v2 10/22] rust: add `ZeroableOption` and implement it instead of `Zeroable` for `Option<Box<T, A>>` Benno Lossin
2025-03-08 11:04 ` [PATCH v2 11/22] rust: pin-init: fix documentation links Benno Lossin
2025-03-18 11:38 ` Andreas Hindborg
2025-03-08 11:04 ` [PATCH v2 12/22] rust: pin-init: remove kernel-crate dependency Benno Lossin
2025-03-08 11:04 ` [PATCH v2 13/22] rust: pin-init: change the way the `paste!` macro is called Benno Lossin
2025-03-08 11:05 ` [PATCH v2 14/22] rust: add pin-init crate build infrastructure Benno Lossin
2025-03-08 11:05 ` [PATCH v2 15/22] rust: make pin-init its own crate Benno Lossin
2025-03-18 11:40 ` Andreas Hindborg
2025-03-08 11:05 ` [PATCH v2 16/22] rust: pin-init: add `std` and `alloc` support from the user-space version Benno Lossin
2025-03-08 11:05 ` [PATCH v2 17/22] rust: pin-init: synchronize documentation with " Benno Lossin
2025-03-08 11:05 ` [PATCH v2 18/22] rust: pin-init: internal: synchronize with " Benno Lossin
2025-03-13 11:22 ` Fiona Behrens
2025-03-08 11:05 ` [PATCH v2 19/22] rust: pin-init: miscellaneous synchronization with the " Benno Lossin
2025-03-13 11:24 ` Fiona Behrens
2025-03-08 11:05 ` [PATCH v2 20/22] rust: pin-init: add miscellaneous files from " Benno Lossin
2025-03-08 11:05 ` [PATCH v2 21/22] rust: pin-init: re-enable doctests Benno Lossin
2025-03-08 11:05 ` [PATCH v2 22/22] MAINTAINERS: add entry for the `pin-init` crate Benno Lossin
2025-03-16 21:07 ` [PATCH v2 00/22] make pin-init into a standalone crate Miguel Ojeda
2025-03-17 10:45 ` Benno Lossin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250308110339.2997091-7-benno.lossin@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).