Skip to content

Commit c59a246

Browse files
committed
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> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent 045dc7d commit c59a246

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

rust/pin-init/internal/src/init.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,12 @@ fn make_field_check(
417417
#[allow(unreachable_code, clippy::diverging_sub_expression, unused_assignments)]
418418
// SAFETY: this code is never executed.
419419
let _ = || unsafe {
420-
let mut zeroed = ::core::mem::zeroed();
421-
// We have to use type inference here to make zeroed have the correct type. This
422-
// does not get executed, so it has no effect.
423-
::core::ptr::write(slot, zeroed);
424-
zeroed = ::core::mem::zeroed();
425420
::core::ptr::write(slot, #path {
426421
#(
427422
#(#field_attrs)*
428423
#field_name: ::core::panic!(),
429424
)*
430-
..zeroed
425+
..::core::mem::zeroed()
431426
})
432427
};
433428
},

0 commit comments

Comments
 (0)