* [PATCH 1/2] rust: pin-init: fix typos
@ 2025-04-26 8:39 Benno Lossin
2025-04-26 8:39 ` [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros Benno Lossin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Benno Lossin @ 2025-04-26 8:39 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens, Christian Schrefl
Cc: rust-for-linux, linux-kernel
Correct two typos in the `Wrapper::pin_init` documentation.
Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/fd0bf5e244b685188dc642fc4a0bd3f042468fdb
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
---
Second round of pin-init syncs for v6.16. Depends on
https://lore.kernel.org/all/20250421221728.528089-1-benno.lossin@proton.me
---
rust/pin-init/src/lib.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
index 05a0cd6ad8f4..b5a295effd9c 100644
--- a/rust/pin-init/src/lib.rs
+++ b/rust/pin-init/src/lib.rs
@@ -1580,7 +1580,7 @@ unsafe impl<$first: Zeroable, $($t: Zeroable),*> Zeroable for ($first, $($t),*)
/// });
/// ```
pub trait Wrapper<T> {
- /// Create an pin-initializer for a [`Self`] containing `T` form the `value_init` initializer.
+ /// Creates an pin-initializer for a [`Self`] containing `T` from the `value_init` initializer.
fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E>;
}
base-commit: 39051adb070432b283e6c11b2b24937281b9f97f
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros
2025-04-26 8:39 [PATCH 1/2] rust: pin-init: fix typos Benno Lossin
@ 2025-04-26 8:39 ` Benno Lossin
2025-04-26 11:36 ` Christian Schrefl
2025-04-26 10:48 ` [PATCH 1/2] rust: pin-init: fix typos Christian Schrefl
2025-05-01 16:38 ` Benno Lossin
2 siblings, 1 reply; 5+ messages in thread
From: Benno Lossin @ 2025-04-26 8:39 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens, Christian Schrefl
Cc: rust-for-linux, linux-kernel
Specify that both `MaybeZeroable` and `Zeroable` work on `union`s. Add a
doc example for a union. Also include an example with visibility on the
field.
Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/ab0985a0e08df06c60a32ca5888f74adcc2c1cf3
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
---
Also see the compile-fail & macro expansion tests added by this commit
(not included in the kernel, since the test files are only upstream):
https://github.com/Rust-for-Linux/pin-init/pull/48/commits/278070d12b41f0fca1b0d6dff6c5f38f3cf46044
---
rust/pin-init/src/lib.rs | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
index b5a295effd9c..9ab34036e6bc 100644
--- a/rust/pin-init/src/lib.rs
+++ b/rust/pin-init/src/lib.rs
@@ -395,9 +395,10 @@
/// ```
pub use ::pin_init_internal::pinned_drop;
-/// Derives the [`Zeroable`] trait for the given struct.
+/// Derives the [`Zeroable`] trait for the given `struct` or `union`.
///
-/// This can only be used for structs where every field implements the [`Zeroable`] trait.
+/// This can only be used for `struct`s/`union`s where every field implements the [`Zeroable`]
+/// trait.
///
/// # Examples
///
@@ -406,14 +407,25 @@
///
/// #[derive(Zeroable)]
/// pub struct DriverData {
-/// id: i64,
+/// pub(crate) id: i64,
/// buf_ptr: *mut u8,
/// len: usize,
/// }
/// ```
+///
+/// ```
+/// use pin_init::Zeroable;
+///
+/// #[derive(Zeroable)]
+/// pub union SignCast {
+/// signed: i64,
+/// unsigned: u64,
+/// }
+/// ```
pub use ::pin_init_internal::Zeroable;
-/// Derives the [`Zeroable`] trait for the given struct if all fields implement [`Zeroable`].
+/// Derives the [`Zeroable`] trait for the given `struct` or `union` if all fields implement
+/// [`Zeroable`].
///
/// Contrary to the derive macro named [`macro@Zeroable`], this one silently fails when a field
/// doesn't implement [`Zeroable`].
@@ -426,7 +438,7 @@
/// // implmements `Zeroable`
/// #[derive(MaybeZeroable)]
/// pub struct DriverData {
-/// id: i64,
+/// pub(crate) id: i64,
/// buf_ptr: *mut u8,
/// len: usize,
/// }
@@ -434,7 +446,7 @@
/// // does not implmement `Zeroable`
/// #[derive(MaybeZeroable)]
/// pub struct DriverData2 {
-/// id: i64,
+/// pub(crate) id: i64,
/// buf_ptr: *mut u8,
/// len: usize,
/// // this field doesn't implement `Zeroable`
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] rust: pin-init: fix typos
2025-04-26 8:39 [PATCH 1/2] rust: pin-init: fix typos Benno Lossin
2025-04-26 8:39 ` [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros Benno Lossin
@ 2025-04-26 10:48 ` Christian Schrefl
2025-05-01 16:38 ` Benno Lossin
2 siblings, 0 replies; 5+ messages in thread
From: Christian Schrefl @ 2025-04-26 10:48 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens
Cc: rust-for-linux, linux-kernel
On 26.04.25 10:39 AM, Benno Lossin wrote:
> Correct two typos in the `Wrapper::pin_init` documentation.
>
> Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/fd0bf5e244b685188dc642fc4a0bd3f042468fdb
> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
> ---
> Second round of pin-init syncs for v6.16. Depends on
>
> https://lore.kernel.org/all/20250421221728.528089-1-benno.lossin@proton.me
> ---
> rust/pin-init/src/lib.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
> index 05a0cd6ad8f4..b5a295effd9c 100644
> --- a/rust/pin-init/src/lib.rs
> +++ b/rust/pin-init/src/lib.rs
> @@ -1580,7 +1580,7 @@ unsafe impl<$first: Zeroable, $($t: Zeroable),*> Zeroable for ($first, $($t),*)
> /// });
> /// ```
> pub trait Wrapper<T> {
> - /// Create an pin-initializer for a [`Self`] containing `T` form the `value_init` initializer.
> + /// Creates an pin-initializer for a [`Self`] containing `T` from the `value_init` initializer.
> fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E>;
> }
>
>
> base-commit: 39051adb070432b283e6c11b2b24937281b9f97f
Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros
2025-04-26 8:39 ` [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros Benno Lossin
@ 2025-04-26 11:36 ` Christian Schrefl
0 siblings, 0 replies; 5+ messages in thread
From: Christian Schrefl @ 2025-04-26 11:36 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens
Cc: rust-for-linux, linux-kernel
On 26.04.25 10:39 AM, Benno Lossin wrote:
> Specify that both `MaybeZeroable` and `Zeroable` work on `union`s. Add a
> doc example for a union. Also include an example with visibility on the
> field.
>
> Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/ab0985a0e08df06c60a32ca5888f74adcc2c1cf3
> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
> ---
> Also see the compile-fail & macro expansion tests added by this commit
> (not included in the kernel, since the test files are only upstream):
>
> https://github.com/Rust-for-Linux/pin-init/pull/48/commits/278070d12b41f0fca1b0d6dff6c5f38f3cf46044
> ---
Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] rust: pin-init: fix typos
2025-04-26 8:39 [PATCH 1/2] rust: pin-init: fix typos Benno Lossin
2025-04-26 8:39 ` [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros Benno Lossin
2025-04-26 10:48 ` [PATCH 1/2] rust: pin-init: fix typos Christian Schrefl
@ 2025-05-01 16:38 ` Benno Lossin
2 siblings, 0 replies; 5+ messages in thread
From: Benno Lossin @ 2025-05-01 16:38 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens, Christian Schrefl
Cc: rust-for-linux, linux-kernel
On Sat Apr 26, 2025 at 10:39 AM CEST, Benno Lossin wrote:
> Correct two typos in the `Wrapper::pin_init` documentation.
>
> Link: https://github.com/Rust-for-Linux/pin-init/pull/48/commits/fd0bf5e244b685188dc642fc4a0bd3f042468fdb
> Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Applied both to pin-init-next -- thanks everyone!
---
Cheers,
Benno
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-01 16:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-26 8:39 [PATCH 1/2] rust: pin-init: fix typos Benno Lossin
2025-04-26 8:39 ` [PATCH 2/2] rust: pin-init: improve documentation for `Zeroable` derive macros Benno Lossin
2025-04-26 11:36 ` Christian Schrefl
2025-04-26 10:48 ` [PATCH 1/2] rust: pin-init: fix typos Christian Schrefl
2025-05-01 16:38 ` Benno Lossin
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).