Skip to content

Commit 1975b8d

Browse files
committed
Document that slices cannot be larger than isize::MAX bytes
Fixes #53676.
1 parent 4efc0a7 commit 1975b8d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libcore/slice/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,6 +3851,9 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38513851
/// them from other data. You can obtain a pointer that is usable as `data`
38523852
/// for zero-length slices using [`NonNull::dangling()`].
38533853
///
3854+
/// The total size of the slice must be no larger than `isize::MAX` **bytes**
3855+
/// in memory. See the safety documentation of [`pointer::offset`].
3856+
///
38543857
/// # Caveat
38553858
///
38563859
/// The lifetime for the returned slice is inferred from its usage. To
@@ -3872,6 +3875,7 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38723875
/// ```
38733876
///
38743877
/// [`NonNull::dangling()`]: ../../std/ptr/struct.NonNull.html#method.dangling
3878+
/// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset
38753879
#[inline]
38763880
#[stable(feature = "rust1", since = "1.0.0")]
38773881
pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {

0 commit comments

Comments
 (0)