Skip to content

Commit 7a4bdc5

Browse files
committed
Auto merge of #106967 - saethlin:remove-vec-as-ptr-assume, r=thomcc
Remove the assume(!is_null) from Vec::as_ptr At a guess, this code is leftover from LLVM was worse at keeping track of the niche information here. In any case, we don't need this anymore: Removing this `assume` doesn't get rid of the `nonnull` attribute on the return type.
2 parents 6a6522d + db02d81 commit 7a4bdc5

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

alloc/src/vec/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ use core::cmp::Ordering;
5959
use core::convert::TryFrom;
6060
use core::fmt;
6161
use core::hash::{Hash, Hasher};
62-
use core::intrinsics::assume;
6362
use core::iter;
6463
#[cfg(not(no_global_oom_handling))]
6564
use core::iter::FromIterator;
@@ -1240,11 +1239,7 @@ impl<T, A: Allocator> Vec<T, A> {
12401239
pub fn as_ptr(&self) -> *const T {
12411240
// We shadow the slice method of the same name to avoid going through
12421241
// `deref`, which creates an intermediate reference.
1243-
let ptr = self.buf.ptr();
1244-
unsafe {
1245-
assume(!ptr.is_null());
1246-
}
1247-
ptr
1242+
self.buf.ptr()
12481243
}
12491244

12501245
/// Returns an unsafe mutable pointer to the vector's buffer, or a dangling
@@ -1277,11 +1272,7 @@ impl<T, A: Allocator> Vec<T, A> {
12771272
pub fn as_mut_ptr(&mut self) -> *mut T {
12781273
// We shadow the slice method of the same name to avoid going through
12791274
// `deref_mut`, which creates an intermediate reference.
1280-
let ptr = self.buf.ptr();
1281-
unsafe {
1282-
assume(!ptr.is_null());
1283-
}
1284-
ptr
1275+
self.buf.ptr()
12851276
}
12861277

12871278
/// Returns a reference to the underlying allocator.

0 commit comments

Comments
 (0)