diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-12-12 15:47:32 +0100 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-12-13 18:08:35 +0100 |
| commit | 8b2a7da3b0d5ef813c3ecbdde2a550eedef27712 (patch) | |
| tree | 6471bae4f793ac97778d715ff17ef4e4bed3ad05 /library/core | |
| parent | 32da2305880765a4c76180086959a2d5da131565 (diff) | |
| download | rust-8b2a7da3b0d5ef813c3ecbdde2a550eedef27712.tar.gz rust-8b2a7da3b0d5ef813c3ecbdde2a550eedef27712.zip | |
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.
Diffstat (limited to 'library/core')
| -rw-r--r-- | library/core/src/intrinsics.rs | 7 | ||||
| -rw-r--r-- | library/core/src/mem/mod.rs | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 7ed7d767f2f..ed58a7f1799 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -959,13 +959,14 @@ extern "rust-intrinsic" { #[rustc_safe_intrinsic] pub fn assert_zero_valid<T>(); - /// A guard for unsafe functions that cannot ever be executed if `T` has invalid - /// bit patterns: This will statically either panic, or do nothing. + /// A guard for `std::mem::uninitialized`. Checks whether a repeated bit pattern `0x01` + /// is legal for `T`: This will statically either panic, or do nothing. /// /// This intrinsic does not have a stable counterpart. #[rustc_const_unstable(feature = "const_assert_type2", issue = "none")] #[rustc_safe_intrinsic] - pub fn assert_uninit_valid<T>(); + #[cfg(not(bootstrap))] + pub fn assert_mem_uninitialized_valid<T>(); /// Gets a reference to a static `Location` indicating where it was called. /// diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 383bdc7b6e2..5e01ccc07d8 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -682,7 +682,8 @@ pub unsafe fn zeroed<T>() -> T { pub unsafe fn uninitialized<T>() -> T { // SAFETY: the caller must guarantee that an uninitialized value is valid for `T`. unsafe { - intrinsics::assert_uninit_valid::<T>(); + #[cfg(not(bootstrap))] // If the compiler hits this itself then it deserves the UB. + intrinsics::assert_mem_uninitialized_valid::<T>(); let mut val = MaybeUninit::<T>::uninit(); // Fill memory with 0x01, as an imperfect mitigation for old code that uses this function on |
