Document NonNull layout guarantees#158325
Conversation
|
|
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @RalfJung (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
@rustbot review |
|
No worries, this is in my queue. The queue is just particularly long right now since I was traveling for 2 weeks and came back to around 300 emails in my inbox. It takes a while to go through all that. |
|
@RalfJung has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
This pull request was unapproved. |
|
Yup, seems entirely non-controversial 👍 |
| /// | ||
| /// `NonNull<T>` is guaranteed to have the same layout and bit validity as `*mut T` | ||
| /// with the exception that a null pointer is invalid. | ||
| /// `Option<NonNull<T>>` is guaranteed to be compatible with `*mut T`, including in |
There was a problem hiding this comment.
| /// `Option<NonNull<T>>` is guaranteed to be compatible with `*mut T`, including in | |
| /// `Option<NonNull<T>>` is guaranteed to be ABI-compatible with `*mut T`, including in |
Does the word "compatible" on its own have a well-defined meaning?
There was a problem hiding this comment.
I don't know, but if we change this we should also change it for NonZero*.
There was a problem hiding this comment.
Yeah i think it's better to change that in both cases
|
Pondering: when we're talking ABI-compatibility in signatures, how do we square LLVM attributes like |
|
I think you're thinking about #46188 ? |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
|
@bors r+ rollup Thanks all :) |
|
📋 This PR cannot be approved because it currently has the following label: |
|
@bors r+ rollup |
Document NonNull layout guarantees As discussed [here](rust-lang#157982 (comment)) Fixes rust-lang#157741 This updates the `NonNull` layout docs to match the structure and wording used by `NonZero`. - adds the missing `NonNull<T>` layout and validity wording, and documents that `Option<NonNull<T>>` is compatible with `*mut T`, including in FFI. r? @RalfJung
Rollup of 11 pull requests Successful merges: - #159210 (`rust-analyzer` subtree update) - #158655 (Fix coroutine MIR saved local remapping) - #159205 (bootstrap: Replace `ShouldRun::crates` with `crate_or_deps_filtered`) - #159208 (Fix `attr_on_non_tail_expr` typo) - #157524 (Fix relative paths in private import suggestions) - #158325 (Document NonNull layout guarantees) - #158882 (enable `do_not_recommend` attr for method call errors in current solver) - #158982 (Pretty-print MIR user types too.) - #159069 (Add codegen test for constant returns after local use) - #159163 (rustc_target: Add acquire-release to implied features of v8) - #159201 (borrowck: Represent 'best blame constraint' as index into `Vec<OutlivesConstraint>`)
Rollup of 11 pull requests Successful merges: - #159210 (`rust-analyzer` subtree update) - #158655 (Fix coroutine MIR saved local remapping) - #159205 (bootstrap: Replace `ShouldRun::crates` with `crate_or_deps_filtered`) - #159208 (Fix `attr_on_non_tail_expr` typo) - #157524 (Fix relative paths in private import suggestions) - #158325 (Document NonNull layout guarantees) - #158882 (enable `do_not_recommend` attr for method call errors in current solver) - #158982 (Pretty-print MIR user types too.) - #159069 (Add codegen test for constant returns after local use) - #159163 (rustc_target: Add acquire-release to implied features of v8) - #159201 (borrowck: Represent 'best blame constraint' as index into `Vec<OutlivesConstraint>`)
Rollup merge of #158325 - 0xEgao:docs-non-null, r=RalfJung Document NonNull layout guarantees As discussed [here](#157982 (comment)) Fixes #157741 This updates the `NonNull` layout docs to match the structure and wording used by `NonZero`. - adds the missing `NonNull<T>` layout and validity wording, and documents that `Option<NonNull<T>>` is compatible with `*mut T`, including in FFI. r? @RalfJung
View all comments
As discussed here
Fixes #157741
This updates the
NonNulllayout docs to match the structure and wording used byNonZero.NonNull<T>layout and validity wording, and documents thatOption<NonNull<T>>is compatible with*mut T, including in FFI.r? @RalfJung