Skip to content

Commit 9597744

Browse files
authored
Rollup merge of #74450 - aticu:master, r=jonas-schievink
Fix `Safety` docs for `from_raw_parts_mut` This aligns the wording more with the documentation of e.g. `drop_in_place`, `replace`, `swap` and `swap_nonoverlapping` from `core::ptr`. Also if the pointer were really only valid for writes, it would be trivial to introduce UB from safe code, after calling `core::slice::from_raw_parts_mut`.
2 parents 18e8089 + 4127ed1 commit 9597744

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/slice/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6095,7 +6095,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
60956095
///
60966096
/// Behavior is undefined if any of the following conditions are violated:
60976097
///
6098-
/// * `data` must be [valid] for writes for `len * mem::size_of::<T>()` many bytes,
6098+
/// * `data` must be [valid] for boths reads and writes for `len * mem::size_of::<T>()` many bytes,
60996099
/// and it must be properly aligned. This means in particular:
61006100
///
61016101
/// * The entire memory range of this slice must be contained within a single allocated object!

0 commit comments

Comments
 (0)