Skip to content

Commit bfb0e41

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 c56d85e commit bfb0e41

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
@@ -415,17 +415,12 @@ fn make_field_check(
415415
#[allow(unreachable_code, clippy::diverging_sub_expression, unused_assignments)]
416416
// SAFETY: this code is never executed.
417417
let _ = || unsafe {
418-
let mut zeroed = ::core::mem::zeroed();
419-
// We have to use type inference here to make zeroed have the correct type. This
420-
// does not get executed, so it has no effect.
421-
::core::ptr::write(slot, zeroed);
422-
zeroed = ::core::mem::zeroed();
423418
::core::ptr::write(slot, #path {
424419
#(
425420
#(#field_attrs)*
426421
#field_name: ::core::panic!(),
427422
)*
428-
..zeroed
423+
..::core::mem::zeroed()
429424
})
430425
};
431426
},

0 commit comments

Comments
 (0)