diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-31 14:30:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-31 14:30:43 +0100 |
| commit | 852440ba5fddd950dd09728bd621f5a13683f101 (patch) | |
| tree | 41e2af7ab58d5382ea4271f65b4e979bae7ecf5e /library | |
| parent | d08d13252483d76b6a9d54459659cfca84cbdfe3 (diff) | |
| parent | d9ef419c90fff3797e8069979272c51c547119bb (diff) | |
| download | rust-852440ba5fddd950dd09728bd621f5a13683f101.tar.gz rust-852440ba5fddd950dd09728bd621f5a13683f101.zip | |
Rollup merge of #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 #134912](https://github.com/rust-lang/rust/pull/134912) > the _unaligned method docs should be fixed.
Diffstat (limited to 'library')
| -rw-r--r-- | library/core/src/ptr/mod.rs | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index dd61848d6e8..a70af793004 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -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 /// @@ -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 |
