libs: use assert_unchecked
instead of intrinsic
This commit is contained in:
parent
174e73a3f6
commit
fa9a911a57
15 changed files with 28 additions and 22 deletions
|
@ -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)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue