Closed
Description
I tried this code:
use std::mem::MaybeUninit;
pub const fn foo() -> MaybeUninit<[u8; 10]> {
const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit();
M
}
pub const fn bar() -> MaybeUninit<[u8; 10]> {
MaybeUninit::uninit()
}
I expected to see this happen: Both functions to compile to just a return instruction
Instead, this happened: Only bar
did, foo
zeros the return value in release builds.
playground::foo: # @playground::foo
# %bb.0:
xorl %eax, %eax
xorl %edx, %edx
retq
# -- End function
playground::bar: # @playground::bar
# %bb.0:
retq
# -- End function
Meta
rustc --version --verbose
:
1.53.0-nightly (2021-03-28 4a20eb6a9da36c88ee92)