Skip to content

Commit 80f2692

Browse files
committed
Fix up unsafe section of slice::from_raw_parts
Added a proper Unsafety header, as well as mentioning that the pointer shouldn't be null. Fixes #26552
1 parent 50df2a0 commit 80f2692

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libcore/slice.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1368,10 +1368,14 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
13681368
///
13691369
/// The `len` argument is the number of **elements**, not the number of bytes.
13701370
///
1371+
/// # Unsafety
1372+
///
13711373
/// This function is unsafe as there is no guarantee that the given pointer is
13721374
/// valid for `len` elements, nor whether the lifetime inferred is a suitable
13731375
/// lifetime for the returned slice.
13741376
///
1377+
/// `p` must be non-null, even for zero-length slices.
1378+
///
13751379
/// # Caveat
13761380
///
13771381
/// The lifetime for the returned slice is inferred from its usage. To

0 commit comments

Comments
 (0)