diff options
| author | Benno Lossin <lossin@kernel.org> | 2026-01-16 11:54:29 +0100 |
|---|---|---|
| committer | Benno Lossin <lossin@kernel.org> | 2026-01-17 10:51:43 +0100 |
| commit | 1f1cd6964bbc37f2cc82a0adc8a0acec34af1afb (patch) | |
| tree | 316144798754a604e07eb7241fbb4e8ba14cde28 /rust | |
| parent | ceca298c53f9300ea689207f9ae9a3da3b4b4c4f (diff) | |
rust: pin-init: internal: init: simplify Zeroable safety check
The `Zeroable` type check uses a small dance with a raw pointer to aid
type inference. It turns out that this is not necessary and type
inference is powerful enough to resolve any ambiguity. Thus remove it.
Suggested-by: Gary Guo <gary@garyguo.net>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Benno Lossin <lossin@kernel.org>
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/pin-init/internal/src/init.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/rust/pin-init/internal/src/init.rs b/rust/pin-init/internal/src/init.rs index ed2e1462e176..42936f915a07 100644 --- a/rust/pin-init/internal/src/init.rs +++ b/rust/pin-init/internal/src/init.rs @@ -414,17 +414,12 @@ fn make_field_check( #[allow(unreachable_code, clippy::diverging_sub_expression, unused_assignments)] // SAFETY: this code is never executed. let _ = || unsafe { - let mut zeroed = ::core::mem::zeroed(); - // We have to use type inference here to make zeroed have the correct type. This - // does not get executed, so it has no effect. - ::core::ptr::write(slot, zeroed); - zeroed = ::core::mem::zeroed(); ::core::ptr::write(slot, #path { #( #(#field_attrs)* #field_name: ::core::panic!(), )* - ..zeroed + ..::core::mem::zeroed() }) }; }, |
