mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
Rollup merge of #76665 - RalfJung:slice-from-raw, r=sfackler
slice::from_raw_parts: explicitly mention that data must be initialized This reflects the status quo, until the discussion in https://github.com/rust-lang/unsafe-code-guidelines/issues/77 reaches a conclusion.
This commit is contained in:
commit
305d63c2a4
@ -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`
|
/// them from other data. You can obtain a pointer that is usable as `data`
|
||||||
/// for zero-length slices using [`NonNull::dangling()`].
|
/// 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
|
/// * The memory referenced by the returned slice must not be mutated for the duration
|
||||||
/// of lifetime `'a`, except inside an `UnsafeCell`.
|
/// of lifetime `'a`, except inside an `UnsafeCell`.
|
||||||
///
|
///
|
||||||
@ -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`
|
/// them from other data. You can obtain a pointer that is usable as `data`
|
||||||
/// for zero-length slices using [`NonNull::dangling()`].
|
/// 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
|
/// * 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`.
|
/// (not derived from the return value) for the duration of lifetime `'a`.
|
||||||
/// Both read and write accesses are forbidden.
|
/// Both read and write accesses are forbidden.
|
||||||
|
Loading…
Reference in New Issue
Block a user