Skip to content

Commit 0d640ef

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 <[email protected]> Signed-off-by: Benno Lossin <[email protected]>
1 parent f077323 commit 0d640ef

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

internal/src/init.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,12 @@ fn make_field_check(
410410
#[allow(unreachable_code, clippy::diverging_sub_expression, unused_assignments)]
411411
// SAFETY: this code is never executed.
412412
let _ = || unsafe {
413-
let mut zeroed = ::core::mem::zeroed();
414-
// We have to use type inference here to make zeroed have the correct type. This
415-
// does not get executed, so it has no effect.
416-
::core::ptr::write(slot, zeroed);
417-
zeroed = ::core::mem::zeroed();
418413
::core::ptr::write(slot, #path {
419414
#(
420415
#(#field_attrs)*
421416
#field_name: ::core::panic!(),
422417
)*
423-
..zeroed
418+
..::core::mem::zeroed()
424419
})
425420
};
426421
},

0 commit comments

Comments
 (0)