Skip to content

Improve documentation of align_of and Alignment.#157500

Open
kpreid wants to merge 1 commit into
rust-lang:mainfrom
kpreid:align-doc
Open

Improve documentation of align_of and Alignment.#157500
kpreid wants to merge 1 commit into
rust-lang:mainfrom
kpreid:align-doc

Conversation

@kpreid
Copy link
Copy Markdown
Contributor

@kpreid kpreid commented Jun 5, 2026

  • The documentation for align_of_val() and Alignment::of_val() did not explain its use in interacting with dyn types, and even contained the false statement that “Every reference to a value of the type T must be a multiple of this number”. This change removes that statement from everything except align_of(), and adds a mention of, and example code for, getting the alignment of a dyn value.

  • The documentation for align_of_val_raw() did not explain how it relates to other functions in the family. Now it does.

  • Added a caveat that the alignment of i32 is not always 4, despite the examples asserting this.

@rustbot label A-docs

* The documentation for `align_of_val()` and `Alignment::of_val()` did
  not explain its use in interacting with `dyn` types, and even
  contained the false statement that “Every reference to a value of the
  type `T` must be a multiple of this number”. This change removes that
  statement from everything except `align_of()`, and adds a mention
  of, and example code for, getting the alignment of a `dyn` value.

* The documentation for `align_of_val_raw()` did not explain how it
  relates to other functions in the family. Now it does.

* Added a caveat that the alignment of `i32` is not always 4, despite
  the examples asserting this.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 5, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 9 candidates
  • Random selection from LawnGnome, Mark-Simulacrum, clarfonthey, jhpratt

@rustbot rustbot added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

3 participants