Skip to content

Commit 7048167

Browse files
committed
Stabilize const_mem_zeroed
Make `core::mem::zeroed` const stable. Newly stable API: // core::mem pub const unsafe fn zeroed<T>() -> T; This is stabilized with `const_maybe_uninit_zeroed` since it is a simple wrapper.
1 parent 5aac56c commit 7048167

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ extern "rust-intrinsic" {
10721072
/// zero-initialization: This will statically either panic, or do nothing.
10731073
///
10741074
/// This intrinsic does not have a stable counterpart.
1075-
#[rustc_const_unstable(feature = "const_assert_type2", issue = "none")]
1075+
#[rustc_const_stable(feature = "const_assert_zero_valid", since = "CURRENT_RUSTC_VERSION")]
10761076
#[rustc_safe_intrinsic]
10771077
#[rustc_nounwind]
10781078
pub fn assert_zero_valid<T>();

library/core/src/mem/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ pub const fn needs_drop<T: ?Sized>() -> bool {
647647
#[allow(deprecated)]
648648
#[rustc_diagnostic_item = "mem_zeroed"]
649649
#[track_caller]
650-
pub unsafe fn zeroed<T>() -> T {
650+
#[rustc_const_stable(feature = "const_mem_zeroed", since = "CURRENT_RUSTC_VERSION")]
651+
pub const unsafe fn zeroed<T>() -> T {
651652
// SAFETY: the caller must guarantee that an all-zero value is valid for `T`.
652653
unsafe {
653654
intrinsics::assert_zero_valid::<T>();

0 commit comments

Comments
 (0)