Skip to content

Commit

Permalink
Unrolled build for rust-lang#134953
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#134953 - DiuDiu777:unaligned-doc, r=RalfJung

Fix doc for read&write unaligned in zst operation

### PR Description
This PR addresses an inconsistency in the Rust documentation regarding `read_unaligned ` and `write_unaligned` on zero-sized types (ZSTs). The current documentation for [pointer validity](https://doc.rust-lang.org/nightly/std/ptr/index.html#safety) states that for zero-sized types (ZSTs), null pointers are valid:
> For zero-sized types (ZSTs), every pointer is valid, including the null pointer.

However, there is an inconsistency in the documentation for the unaligned read operation in the function [ptr::read_unaligned](https://doc.rust-lang.org/nightly/std/ptr/fn.read_unaligned.html)(as well as `write_unaligned`), which states:
> Note that even if T has size 0, the pointer must be non-null.

This change is also supported by [PR rust-lang#134912](rust-lang#134912)
> the _unaligned method docs should be fixed.
  • Loading branch information
rust-timer authored Dec 31, 2024
2 parents 7a0cde9 + d9ef419 commit d598f8f
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,8 +1403,6 @@ pub const unsafe fn read<T>(src: *const T) -> T {
/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned
/// value and the value at `*src` can [violate memory safety][read-ownership].
///
/// Note that even if `T` has size `0`, the pointer must be non-null.
///
/// [read-ownership]: read#ownership-of-the-returned-value
/// [valid]: self#safety
///
Expand Down Expand Up @@ -1611,8 +1609,6 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
///
/// * `dst` must be [valid] for writes.
///
/// Note that even if `T` has size `0`, the pointer must be non-null.
///
/// [valid]: self#safety
///
/// ## On `packed` structs
Expand Down

0 comments on commit d598f8f

Please sign in to comment.