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/alloc/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/alloc/src/alloc.rs')
| -rw-r--r-- | library/alloc/src/alloc.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 1663aa84921..0b142939755 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -3,7 +3,7 @@ #![stable(feature = "alloc_module", since = "1.28.0")] #[cfg(not(test))] -use core::intrinsics; +use core::hint; #[cfg(not(test))] use core::ptr::{self, NonNull}; @@ -208,7 +208,7 @@ impl Global { 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 = realloc(ptr.as_ptr(), old_layout, new_size); let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; @@ -299,7 +299,7 @@ unsafe impl Allocator for Global { // 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 = realloc(ptr.as_ptr(), old_layout, new_size); let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; |
