Skip to content

Fix doc for read&write unaligned in zst operation#134953

Merged
bors merged 1 commit intorust-lang:masterfrom
DiuDiu777:unaligned-doc
Dec 31, 2024
Merged

Fix doc for read&write unaligned in zst operation#134953
bors merged 1 commit intorust-lang:masterfrom
DiuDiu777:unaligned-doc

Conversation

@DiuDiu777
Copy link
Copy Markdown
Contributor

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 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(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

the _unaligned method docs should be fixed.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants