Clarify preconditions of raw size/align methods - #103372
Conversation
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
|
I think it'd perhaps be better worded as something around the shape of
This makes is clearer that "valid for reborrow" is always a sufficient precondition. |
|
The exception/note about reborrowing as &T now appears at both the top and bottom of the list of conditions, which is a bit confusing. Right now it's basically: "This function is safe to call if {A}. Otherwise: {list of conditions}. Otherwise, {A}." Isn't just the note at the start (as suggested by CAD97) enough? |
|
@Jules-Bertholet |
|
Closing this as inactive. Feel free to open a new PR if you wish to continue these changes |
…r=JohnTitor Clarify preconditions of raw size/align methods The current documentation doesn't guarantee that these methods are safe to call for pointers derived from references to new unsized types that Rust may add in the future. Take 2 of rust-lang#103372, wording from @CAD97 in rust-lang#103372 (comment). Tracking issue: rust-lang#69835
…r=JohnTitor Clarify preconditions of raw size/align methods The current documentation doesn't guarantee that these methods are safe to call for pointers derived from references to new unsized types that Rust may add in the future. Take 2 of rust-lang#103372, wording from @CAD97 in rust-lang#103372 (comment). Tracking issue: rust-lang#69835
Rollup merge of #158893 - Jules-Bertholet:for-pointer-docs, r=JohnTitor Clarify preconditions of raw size/align methods The current documentation doesn't guarantee that these methods are safe to call for pointers derived from references to new unsized types that Rust may add in the future. Take 2 of #103372, wording from @CAD97 in #103372 (comment). Tracking issue: #69835
The documentation of the preconditions of
mem::size_of_val_raw,mem::align_of_val_raw, andLayout::for_value_rawwas overly conservative. This PR resolves that problem.Discussion: #69835 (comment)