diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-09-10 07:53:42 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-09-10 07:53:42 +0200 |
| commit | 1aac00fad391d7f714be1401992e95d5dffcb300 (patch) | |
| tree | 758909f7f6239b73bc0c16757e7d6a3ebabb0e77 /src/libcore/slice | |
| parent | 7b77508e233c724bcaf9821f62dbe45dc4b4cdb3 (diff) | |
| download | rust-1aac00fad391d7f714be1401992e95d5dffcb300.tar.gz rust-1aac00fad391d7f714be1401992e95d5dffcb300.zip | |
A slice covering exactly half the address space is not OK
Diffstat (limited to 'src/libcore/slice')
| -rw-r--r-- | src/libcore/slice/mod.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 44d2243c2cc..7fd8e2599f9 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -3852,8 +3852,8 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// -/// The total size of the slice must be no larger than `isize::MAX` **bytes** -/// in memory. See the safety documentation of [`pointer::offset`]. +/// The total size of the slice must lower than `isize::MAX` **bytes** in +/// memory. See the safety documentation of [`pointer::offset`]. /// /// # Caveat /// @@ -3881,7 +3881,7 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> { #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice"); - debug_assert!(len * mem::size_of::<T>() <= isize::MAX as usize, + debug_assert!(len * mem::size_of::<T>() < isize::MAX as usize, "attempt to create slice covering half the address space"); Repr { raw: FatPtr { data, len } }.rust } @@ -3892,8 +3892,8 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { /// This function is unsafe for the same reasons as [`from_raw_parts`], as well /// as not being able to provide a non-aliasing guarantee of the returned /// mutable slice. `data` must be non-null and aligned even for zero-length -/// slices as with [`from_raw_parts`]. The total size of the slice must be no -/// larger than `isize::MAX` **bytes** in memory. See the safety documentation +/// slices as with [`from_raw_parts`]. The total size of the slice must be +/// lower than `isize::MAX` **bytes** in memory. See the safety documentation /// of [`pointer::offset`]. /// /// See the documentation of [`from_raw_parts`] for more details. @@ -3904,7 +3904,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] { debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice"); - debug_assert!(len * mem::size_of::<T>() <= isize::MAX as usize, + debug_assert!(len * mem::size_of::<T>() < isize::MAX as usize, "attempt to create slice covering half the address space"); Repr { raw: FatPtr { data, len} }.rust_mut } |
