Skip to content

Commit dd94ca1

Browse files
committed
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>
1 parent 85d98c5 commit dd94ca1

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

internal/src/init.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,12 @@ fn make_field_check(
414414
#[allow(unreachable_code, clippy::diverging_sub_expression, unused_assignments)]
415415
// SAFETY: this code is never executed.
416416
let _ = || unsafe {
417-
let mut zeroed = ::core::mem::zeroed();
418-
// We have to use type inference here to make zeroed have the correct type. This
419-
// does not get executed, so it has no effect.
420-
::core::ptr::write(slot, zeroed);
421-
zeroed = ::core::mem::zeroed();
422417
::core::ptr::write(slot, #path {
423418
#(
424419
#(#field_attrs)*
425420
#field_name: ::core::panic!(),
426421
)*
427-
..zeroed
422+
..::core::mem::zeroed()
428423
})
429424
};
430425
},

0 commit comments

Comments
 (0)