]> git.lizzy.rs Git - rust.git/commitdiff
Document that slices cannot be larger than `isize::MAX` bytes
authorTobias Bucher <tobiasbucher5991@gmail.com>
Wed, 29 Aug 2018 15:20:17 +0000 (17:20 +0200)
committerTobias Bucher <tobiasbucher5991@gmail.com>
Tue, 4 Sep 2018 09:35:49 +0000 (11:35 +0200)
Fixes #53676.

src/libcore/slice/mod.rs

index 62adaea168a3f97854f935c704331dad8c80701f..7f623486cdf08be6da230c7b78d4e99cd87cfadc 100644 (file)
@@ -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] {