diff options
| author | Ralf Jung <post@ralfj.de> | 2024-02-11 19:04:29 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-02-21 20:15:52 +0100 |
| commit | b58f647d5488dce73bba517907c44af2c2a618c4 (patch) | |
| tree | 24e9b1e2a3299ccd459c5e00db09c64220d6ba21 /library/core/src/slice/iter.rs | |
| parent | 1d447a9946effc38c4b964a888ab408a3df3c246 (diff) | |
| download | rust-b58f647d5488dce73bba517907c44af2c2a618c4.tar.gz rust-b58f647d5488dce73bba517907c44af2c2a618c4.zip | |
rename ptr::invalid -> ptr::without_provenance
also introduce ptr::dangling matching NonNull::dangling
Diffstat (limited to 'library/core/src/slice/iter.rs')
| -rw-r--r-- | library/core/src/slice/iter.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 617b385a960..d7d4f90c1a5 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -12,7 +12,7 @@ use crate::iter::{ use crate::marker::PhantomData; use crate::mem::{self, SizedTypeProperties}; use crate::num::NonZero; -use crate::ptr::{self, invalid, invalid_mut, NonNull}; +use crate::ptr::{self, without_provenance, without_provenance_mut, NonNull}; use super::{from_raw_parts, from_raw_parts_mut}; @@ -67,7 +67,7 @@ pub struct Iter<'a, T: 'a> { ptr: NonNull<T>, /// For non-ZSTs, the non-null pointer to the past-the-end element. /// - /// For ZSTs, this is `ptr::invalid(len)`. + /// For ZSTs, this is `ptr::dangling(len)`. end_or_len: *const T, _marker: PhantomData<&'a T>, } @@ -91,7 +91,8 @@ impl<'a, T> Iter<'a, T> { let ptr: NonNull<T> = NonNull::from(slice).cast(); // SAFETY: Similar to `IterMut::new`. unsafe { - let end_or_len = if T::IS_ZST { invalid(len) } else { ptr.as_ptr().add(len) }; + let end_or_len = + if T::IS_ZST { without_provenance(len) } else { ptr.as_ptr().add(len) }; Self { ptr, end_or_len, _marker: PhantomData } } @@ -189,7 +190,7 @@ pub struct IterMut<'a, T: 'a> { ptr: NonNull<T>, /// For non-ZSTs, the non-null pointer to the past-the-end element. /// - /// For ZSTs, this is `ptr::invalid_mut(len)`. + /// For ZSTs, this is `ptr::without_provenance_mut(len)`. end_or_len: *mut T, _marker: PhantomData<&'a mut T>, } @@ -228,7 +229,8 @@ impl<'a, T> IterMut<'a, T> { // See the `next_unchecked!` and `is_empty!` macros as well as the // `post_inc_start` method for more information. unsafe { - let end_or_len = if T::IS_ZST { invalid_mut(len) } else { ptr.as_ptr().add(len) }; + let end_or_len = + if T::IS_ZST { without_provenance_mut(len) } else { ptr.as_ptr().add(len) }; Self { ptr, end_or_len, _marker: PhantomData } } |
