Skip to content

Commit a8c7176

Browse files
authored
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"
2 parents 3246802 + 876f7a0 commit a8c7176

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎library/core/src/alloc/layout.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Layout {
122122
///
123123
/// # Safety
124124
///
125-
/// This function is unsafe as it does not verify the preconditions from
125+
/// The arguments passed must meet the preconditions from
126126
/// [`Layout::from_size_align`].
127127
#[stable(feature = "alloc_layout", since = "1.28.0")]
128128
#[rustc_const_stable(feature = "const_alloc_layout_unchecked", since = "1.36.0")]

0 commit comments

Comments
 (0)