Skip to content

Commit

Permalink
Rollup merge of #76665 - RalfJung:slice-from-raw, r=sfackler
Browse files Browse the repository at this point in the history
slice::from_raw_parts: explicitly mention that data must be initialized

This reflects the status quo, until the discussion in rust-lang/unsafe-code-guidelines#77 reaches a conclusion.
  • Loading branch information
jonas-schievink authored Sep 13, 2020
2 parents 11a63bc + 46767b1 commit 305d63c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6680,6 +6680,8 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> {
/// them from other data. You can obtain a pointer that is usable as `data`
/// for zero-length slices using [`NonNull::dangling()`].
///
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
///
/// * The memory referenced by the returned slice must not be mutated for the duration
/// of lifetime `'a`, except inside an `UnsafeCell`.
///
Expand Down Expand Up @@ -6767,6 +6769,8 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
/// them from other data. You can obtain a pointer that is usable as `data`
/// for zero-length slices using [`NonNull::dangling()`].
///
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
///
/// * The memory referenced by the returned slice must not be accessed through any other pointer
/// (not derived from the return value) for the duration of lifetime `'a`.
/// Both read and write accesses are forbidden.
Expand Down

0 comments on commit 305d63c

Please sign in to comment.