Skip to content

Commit 3563842

Browse files
committed
Comment in the implementation that the assert isn't guaranteed.
This could be made guaranteed in future because it's UB to fail it right now, but the other way would introduce unsoundness, so this is the best way to add it for now.
1 parent 80ba6dd commit 3563842

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/mem/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ pub unsafe fn uninitialized<T>() -> T {
720720
#[unstable(feature = "mem_conjure_zst", issue = "95383")]
721721
#[track_caller]
722722
pub const unsafe fn conjure_zst<T>() -> T {
723+
// This is not a guarantee exposed to clients, but it'll easily optimize out
724+
// in the sound cases, so we might as well check because we can.
723725
assert!(size_of::<T>() == 0); // FIXME: Use assert_eq! once that's allowed in const
724726

725727
// SAFETY: because the caller must guarantee that it's inhabited and zero-sized,

0 commit comments

Comments
 (0)