Skip to content

Commit 1aac00f

Browse files
committed
A slice covering exactly half the address space is not OK
1 parent 7b77508 commit 1aac00f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libcore/slice/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3852,8 +3852,8 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38523852
/// them from other data. You can obtain a pointer that is usable as `data`
38533853
/// for zero-length slices using [`NonNull::dangling()`].
38543854
///
3855-
/// The total size of the slice must be no larger than `isize::MAX` **bytes**
3856-
/// in memory. See the safety documentation of [`pointer::offset`].
3855+
/// The total size of the slice must lower than `isize::MAX` **bytes** in
3856+
/// memory. See the safety documentation of [`pointer::offset`].
38573857
///
38583858
/// # Caveat
38593859
///
@@ -3881,7 +3881,7 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38813881
#[stable(feature = "rust1", since = "1.0.0")]
38823882
pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
38833883
debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
3884-
debug_assert!(len * mem::size_of::<T>() <= isize::MAX as usize,
3884+
debug_assert!(len * mem::size_of::<T>() < isize::MAX as usize,
38853885
"attempt to create slice covering half the address space");
38863886
Repr { raw: FatPtr { data, len } }.rust
38873887
}
@@ -3892,8 +3892,8 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
38923892
/// This function is unsafe for the same reasons as [`from_raw_parts`], as well
38933893
/// as not being able to provide a non-aliasing guarantee of the returned
38943894
/// mutable slice. `data` must be non-null and aligned even for zero-length
3895-
/// slices as with [`from_raw_parts`]. The total size of the slice must be no
3896-
/// larger than `isize::MAX` **bytes** in memory. See the safety documentation
3895+
/// slices as with [`from_raw_parts`]. The total size of the slice must be
3896+
/// lower than `isize::MAX` **bytes** in memory. See the safety documentation
38973897
/// of [`pointer::offset`].
38983898
///
38993899
/// 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] {
39043904
#[stable(feature = "rust1", since = "1.0.0")]
39053905
pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] {
39063906
debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
3907-
debug_assert!(len * mem::size_of::<T>() <= isize::MAX as usize,
3907+
debug_assert!(len * mem::size_of::<T>() < isize::MAX as usize,
39083908
"attempt to create slice covering half the address space");
39093909
Repr { raw: FatPtr { data, len} }.rust_mut
39103910
}

0 commit comments

Comments
 (0)