@@ -3839,10 +3839,9 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38393839/// valid for `len` elements, nor whether the lifetime inferred is a suitable
38403840/// lifetime for the returned slice.
38413841///
3842- /// `p` must be non-null, even for zero-length slices, because non-zero bits
3843- /// are required to distinguish between a zero-length slice within `Some()`
3844- /// from `None`. `p` can be a bogus non-dereferencable pointer, such as `0x1`,
3845- /// for zero-length slices, though.
3842+ /// `p` must be non-null and aligned, even for zero-length slices, as is
3843+ /// required for all references. However, for zero-length slices, `p` can be
3844+ /// a bogus non-dereferencable pointer such as [`NonNull::dangling()`].
38463845///
38473846/// # Caveat
38483847///
@@ -3864,6 +3863,8 @@ unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> {
38643863/// let slice = slice::from_raw_parts(ptr, amt);
38653864/// }
38663865/// ```
3866+ ///
3867+ /// [`NonNull::dangling()`]: ../../std/ptr/struct.NonNull.html#method.dangling
38673868#[ inline]
38683869#[ stable( feature = "rust1" , since = "1.0.0" ) ]
38693870pub unsafe fn from_raw_parts < ' a , T > ( data : * const T , len : usize ) -> & ' a [ T ] {
@@ -3875,7 +3876,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
38753876///
38763877/// This function is unsafe for the same reasons as `from_raw_parts`, as well
38773878/// as not being able to provide a non-aliasing guarantee of the returned
3878- /// mutable slice. `p` must be non-null even for zero-length slices as with
3879+ /// mutable slice. `p` must be non-null and aligned even for zero-length slices as with
38793880/// `from_raw_parts`.
38803881#[ inline]
38813882#[ stable( feature = "rust1" , since = "1.0.0" ) ]
0 commit comments