diff options
| author | bors <bors@rust-lang.org> | 2024-01-23 06:45:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-23 06:45:58 +0000 |
| commit | e35a56d96f7d9d4422f2b7b00bf0bf282b2ec782 (patch) | |
| tree | dae003e9517d57f7f1029a94bf136b1b21cc877f /library/std/src/alloc.rs | |
| parent | 0011fac90d2846ea3c04506238ff6e4ed3ce0efe (diff) | |
| parent | 638439a4404d9ef2da4027585134487875787e1d (diff) | |
Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviper
Use `assert_unchecked` instead of `assume` intrinsic in the standard library Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library. CC #119131
Diffstat (limited to 'library/std/src/alloc.rs')
| -rw-r--r-- | library/std/src/alloc.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index bb786bd59dc..a834b36697c 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -56,7 +56,7 @@ #![deny(unsafe_op_in_unsafe_fn)] #![stable(feature = "alloc_module", since = "1.28.0")] -use core::intrinsics; +use core::hint; use core::ptr::NonNull; use core::sync::atomic::{AtomicPtr, Ordering}; use core::{mem, ptr}; @@ -172,7 +172,7 @@ impl System { let new_size = new_layout.size(); // `realloc` probably checks for `new_size >= old_layout.size()` or something similar. - intrinsics::assume(new_size >= old_layout.size()); + hint::assert_unchecked(new_size >= old_layout.size()); let raw_ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), old_layout, new_size); let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; @@ -264,7 +264,7 @@ unsafe impl Allocator for System { // SAFETY: `new_size` is non-zero. Other conditions must be upheld by the caller new_size if old_layout.align() == new_layout.align() => unsafe { // `realloc` probably checks for `new_size <= old_layout.size()` or something similar. - intrinsics::assume(new_size <= old_layout.size()); + hint::assert_unchecked(new_size <= old_layout.size()); let raw_ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), old_layout, new_size); let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; |
