summaryrefslogtreecommitdiffstats
path: root/rust/alloc/raw_vec.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/alloc/raw_vec.rs')
-rw-r--r--rust/alloc/raw_vec.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/rust/alloc/raw_vec.rs b/rust/alloc/raw_vec.rs
index 98b6abf30af6..1839d1c8ee7a 100644
--- a/rust/alloc/raw_vec.rs
+++ b/rust/alloc/raw_vec.rs
@@ -4,7 +4,7 @@
use core::alloc::LayoutError;
use core::cmp;
-use core::intrinsics;
+use core::hint;
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
use core::ptr::{self, NonNull, Unique};
use core::slice;
@@ -317,7 +317,7 @@ impl<T, A: Allocator> RawVec<T, A> {
///
/// # Panics
///
- /// Panics if the new capacity exceeds `isize::MAX` bytes.
+ /// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Aborts
///
@@ -358,7 +358,7 @@ impl<T, A: Allocator> RawVec<T, A> {
}
unsafe {
// Inform the optimizer that the reservation has succeeded or wasn't needed
- core::intrinsics::assume(!self.needs_to_grow(len, additional));
+ hint::assert_unchecked(!self.needs_to_grow(len, additional));
}
Ok(())
}
@@ -381,7 +381,7 @@ impl<T, A: Allocator> RawVec<T, A> {
///
/// # Panics
///
- /// Panics if the new capacity exceeds `isize::MAX` bytes.
+ /// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Aborts
///
@@ -402,7 +402,7 @@ impl<T, A: Allocator> RawVec<T, A> {
}
unsafe {
// Inform the optimizer that the reservation has succeeded or wasn't needed
- core::intrinsics::assume(!self.needs_to_grow(len, additional));
+ hint::assert_unchecked(!self.needs_to_grow(len, additional));
}
Ok(())
}
@@ -553,7 +553,7 @@ where
debug_assert_eq!(old_layout.align(), new_layout.align());
unsafe {
// The allocator checks for alignment equality
- intrinsics::assume(old_layout.align() == new_layout.align());
+ hint::assert_unchecked(old_layout.align() == new_layout.align());
alloc.grow(ptr, old_layout, new_layout)
}
} else {
@@ -591,7 +591,6 @@ fn handle_reserve(result: Result<(), TryReserveError>) {
// `> isize::MAX` bytes will surely fail. On 32-bit and 16-bit we need to add
// an extra guard for this in case we're running on a platform which can use
// all 4GB in user-space, e.g., PAE or x32.
-
#[inline]
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
if usize::BITS < 64 && alloc_size > isize::MAX as usize {