Repository navigation
Tweak Layout::from_size_align_unchecked safety comment - #163288
Merged
rust-bors[bot] merged 1 commit intoSep 25, 2026
Merged
Conversation
Collaborator
|
r? @LawnGnome rustbot has assigned @LawnGnome. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
@bors r+ rollup |
Contributor
|
⌛ Commit 876f7a0 has been tentatively approved by |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 25, 2026
Rollup of 7 pull requests Successful merges: - #160068 (Preserve explicit register names in inline asm diagnostics) - #163239 (Fix applicability level for cfg suggestion) - #163025 (make `Complex` ABI GCC-compatible on sparc) - #163076 (powerpc64: don't pass unions in FPRs on ELFv1) - #163268 ([rustdoc] Correctly check that an item is not `doc(hidden)` with `--generate-link-to-definition`) - #163288 (Tweak Layout::from_size_align_unchecked safety comment) - #163292 (moving div_ceil() to associated items macro)
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 25, 2026
Rollup merge of #163288 - ultrabear:ultrabear/layout-from-size-align, r=thomcc Tweak Layout::from_size_align_unchecked safety comment This slightly tweaks wording of the Safety "contract" of Layout::from_size_align_unchecked. In my opinion, safety comments on function documentation should specify "here is how to safely use this function" rather than the more indirect form of "this function is unsafe because ...". In this case the current docs are clear to me on how to use the function properly, but Its very uncommon that I see the safety comment worded in this sort of roundabout way, and typically when I see it in other crates its a lower quality safety comment that says something like "this function is unsafe because it uses a raw pointer", so I may just associate it with being a more wrong way to write the docs anyways. Thought it worthwhile to open a PR for it to make it more direct and see what others think about "the ~right~ better way to word safety contracts"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This slightly tweaks wording of the Safety "contract" of Layout::from_size_align_unchecked. In my opinion, safety comments on function documentation should specify "here is how to safely use this function" rather than the more indirect form of "this function is unsafe because ...".
In this case the current docs are clear to me on how to use the function properly, but Its very uncommon that I see the safety comment worded in this sort of roundabout way, and typically when I see it in other crates its a lower quality safety comment that says something like "this function is unsafe because it uses a raw pointer", so I may just associate it with being a more wrong way to write the docs anyways.
Thought it worthwhile to open a PR for it to make it more direct and see what others think about "the
rightbetter way to word safety contracts"