]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: pin-init: add `?Sized` bounds to traits in `#[pin_data]` macro
authorBenno Lossin <lossin@kernel.org>
Fri, 16 Jan 2026 10:54:23 +0000 (11:54 +0100)
committerBenno Lossin <lossin@kernel.org>
Sat, 17 Jan 2026 09:51:42 +0000 (10:51 +0100)
commitdae5466c4aa5b43a6cda4282bf9ff8e6b42ece0e
treec97cfb2eebdcf077b8ccb01d07ae7ad93de251fe
parent560f6d13c33f9f06ca34c14dc7c0a045d949c4a0
rust: pin-init: add `?Sized` bounds to traits in `#[pin_data]` macro

The `#[pin_data]` macro uses some auxiliary traits to ensure that a user
does not implement `Drop` for the annotated struct, as that is unsound
and can lead to UB. However, if the struct that is annotated is
`!Sized`, the current bounds do not work, because `Sized` is an implicit
bound for generics.

This is *not* a soundness hole of pin-init, as it currently is
impossible to construct an unsized struct using pin-init.

Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Benno Lossin <lossin@kernel.org>
rust/pin-init/internal/src/pin_data.rs