Skip to content

Commit 88d1d2e

Browse files
committed
Add a comment in MaybeUninit::uninit
1 parent ead2221 commit 88d1d2e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ impl<T> MaybeUninit<T> {
328328
#[inline(always)]
329329
#[rustc_diagnostic_item = "maybe_uninit_uninit"]
330330
pub const fn uninit() -> MaybeUninit<T> {
331+
// It is very helpful for codegen to know when are writing uninit bytes. MIR optimizations
332+
// currently do not const-propagate unions, but if we create the const manually that can be
333+
// trivially propagated. See #142837.
331334
const { MaybeUninit { uninit: () } }
332335
}
333336

0 commit comments

Comments
 (0)