Skip to content

Commit f687ef4

Browse files
committed
Rename assert_uninit_valid intrinsic
It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that.
1 parent bd29ad4 commit f687ef4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

core/src/intrinsics.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,13 +959,14 @@ extern "rust-intrinsic" {
959959
#[rustc_safe_intrinsic]
960960
pub fn assert_zero_valid<T>();
961961

962-
/// A guard for unsafe functions that cannot ever be executed if `T` has invalid
963-
/// bit patterns: This will statically either panic, or do nothing.
962+
/// A guard for `std::mem::uninitialized`. Checks whether a repeated bit pattern `0x01`
963+
/// is legal for `T`: This will statically either panic, or do nothing.
964964
///
965965
/// This intrinsic does not have a stable counterpart.
966966
#[rustc_const_unstable(feature = "const_assert_type2", issue = "none")]
967967
#[rustc_safe_intrinsic]
968-
pub fn assert_uninit_valid<T>();
968+
#[cfg(not(bootstrap))]
969+
pub fn assert_mem_uninitialized_valid<T>();
969970

970971
/// Gets a reference to a static `Location` indicating where it was called.
971972
///

core/src/mem/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ pub unsafe fn zeroed<T>() -> T {
682682
pub unsafe fn uninitialized<T>() -> T {
683683
// SAFETY: the caller must guarantee that an uninitialized value is valid for `T`.
684684
unsafe {
685-
intrinsics::assert_uninit_valid::<T>();
685+
#[cfg(not(bootstrap))] // If the compiler hits this itself then it deserves the UB.
686+
intrinsics::assert_mem_uninitialized_valid::<T>();
686687
let mut val = MaybeUninit::<T>::uninit();
687688

688689
// Fill memory with 0x01, as an imperfect mitigation for old code that uses this function on

0 commit comments

Comments
 (0)