Add #[rustc_never_returns_null_ptr] to std functions
Add the attribute to standard library functions that are guaranteed to never return null pointers, as their originating data wouldn't allow it.
This commit is contained in:
parent
8cfa4fe6b2
commit
33970db8c6
10 changed files with 22 additions and 0 deletions
|
@ -1233,6 +1233,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
///
|
||||
/// [`as_mut_ptr`]: Vec::as_mut_ptr
|
||||
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
|
||||
#[cfg_attr(not(bootstrap), rustc_never_returns_null_ptr)]
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const T {
|
||||
// We shadow the slice method of the same name to avoid going through
|
||||
|
@ -1266,6 +1267,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// assert_eq!(&*x, &[0, 1, 2, 3]);
|
||||
/// ```
|
||||
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
|
||||
#[cfg_attr(not(bootstrap), rustc_never_returns_null_ptr)]
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut T {
|
||||
// We shadow the slice method of the same name to avoid going through
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue