From 1975b8d21b21d5ede54494d0b7661d6ac14ec6a2 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Wed, 29 Aug 2018 17:20:17 +0200 Subject: [PATCH] Document that slices cannot be larger than `isize::MAX` bytes Fixes #53676. --- src/libcore/slice/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 62adaea168a..7f623486cdf 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -3851,6 +3851,9 @@ fn may_have_side_effect() -> bool { false } /// 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`]. +/// /// # Caveat /// /// The lifetime for the returned slice is inferred from its usage. To @@ -3872,6 +3875,7 @@ fn may_have_side_effect() -> bool { false } /// ``` /// /// [`NonNull::dangling()`]: ../../std/ptr/struct.NonNull.html#method.dangling +/// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { -- 2.44.0