std: refactor explanation of NonNull#141946
Merged
bors merged 1 commit intorust-lang:masterfrom Jun 17, 2025
Merged
Conversation
Streamlined the explanation of covariance for `NonNull<T>`, focusing on practical usage and reducing scary explanation. Added a concise example for cases where invariance is required, showing how to use `PhantomData<Cell<T>> Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Member
Author
|
I've avoided big changes this time, removing some of the “scary” descriptions and replacing them with more practical advice, and adding more specific explanations for the examples. |
Member
|
Hm. I know I filed the issues but I wasn't really expecting to get two PRs immediately and requested on them, I kinda expected them to hit the rotation, and this is a slightly more tricky PR to judge when biased by being the reporter. So I'm going to pass them onto the rotation, sorry! ^^; r? libs |
Collaborator
|
Failed to set assignee to
|
Member
|
lol |
Member
|
@bors r+ rollup |
Collaborator
rust-bors bot
added a commit
that referenced
this pull request
Jun 17, 2025
Rollup of 13 pull requests Successful merges: - #138538 (Make performance description of String::{insert,insert_str,remove} more precise) - #141946 (std: refactor explanation of `NonNull`) - #142216 (Miscellaneous RefCell cleanups) - #142542 (Manually invalidate caches in SimplifyCfg.) - #142563 (Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism) - #142570 (Reject union default field values) - #142584 (Handle same-crate macro for borrowck semicolon suggestion) - #142585 (Update books) - #142586 (Fold unnecessary `visit_struct_field_def` in AstValidator) - #142587 (Make sure to propagate result from `visit_expr_fields`) - #142595 (Revert overeager warning for misuse of `--print native-static-libs`) - #142598 (Set elf e_flags on ppc64 targets according to abi) - #142601 (Add a comment to `FORMAT_VERSION`.) r? `@ghost` `@rustbot` modify labels: rollup <!-- homu-ignore:start --> [Create a similar rollup](https://bors.rust-lang.org/queue/rust?prs=138538,141946,142216,142542,142563,142570,142584,142585,142586,142587,142595,142598,142601) <!-- homu-ignore:end --> try-job: dist-apple-various
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Jun 17, 2025
std: refactor explanation of `NonNull` Fixes rust-lang#141933 I cut out the excessive explanation and used an example to explain how to maintain invariance, but I think what is quoted in the *rust reference* in the document needs to be added with a more layman's explanation and example. (I'm not sure if I deleted too much) r? ``@workingjubilee``
bors
added a commit
that referenced
this pull request
Jun 17, 2025
Rollup of 10 pull requests Successful merges: - #138538 (Make performance description of String::{insert,insert_str,remove} more precise) - #141946 (std: refactor explanation of `NonNull`) - #142216 (Miscellaneous RefCell cleanups) - #142371 (avoid `&mut P<T>` in `visit_expr` etc methods) - #142377 (Try unremapping compiler sources) - #142517 (Windows: Use anonymous pipes in Command) - #142542 (Manually invalidate caches in SimplifyCfg.) - #142563 (Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism) - #142570 (Reject union default field values) - #142584 (Handle same-crate macro for borrowck semicolon suggestion) r? `@ghost` `@rustbot` modify labels: rollup
rust-bors bot
added a commit
that referenced
this pull request
Jun 17, 2025
Rollup of 10 pull requests Successful merges: - #138538 (Make performance description of String::{insert,insert_str,remove} more precise) - #141946 (std: refactor explanation of `NonNull`) - #142216 (Miscellaneous RefCell cleanups) - #142371 (avoid `&mut P<T>` in `visit_expr` etc methods) - #142377 (Try unremapping compiler sources) - #142517 (Windows: Use anonymous pipes in Command) - #142542 (Manually invalidate caches in SimplifyCfg.) - #142563 (Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism) - #142570 (Reject union default field values) - #142584 (Handle same-crate macro for borrowck semicolon suggestion) r? `@ghost` `@rustbot` modify labels: rollup <!-- homu-ignore:start --> [Create a similar rollup](https://bors.rust-lang.org/queue/rust?prs=138538,141946,142216,142371,142377,142517,142542,142563,142570,142584) <!-- homu-ignore:end --> try-job: dist-aarch64-apple
bors
added a commit
that referenced
this pull request
Jun 17, 2025
Rollup of 13 pull requests Successful merges: - #138538 (Make performance description of String::{insert,insert_str,remove} more precise) - #141946 (std: refactor explanation of `NonNull`) - #142216 (Miscellaneous RefCell cleanups) - #142542 (Manually invalidate caches in SimplifyCfg.) - #142563 (Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism) - #142570 (Reject union default field values) - #142584 (Handle same-crate macro for borrowck semicolon suggestion) - #142585 (Update books) - #142586 (Fold unnecessary `visit_struct_field_def` in AstValidator) - #142587 (Make sure to propagate result from `visit_expr_fields`) - #142595 (Revert overeager warning for misuse of `--print native-static-libs`) - #142598 (Set elf e_flags on ppc64 targets according to abi) - #142601 (Add a comment to `FORMAT_VERSION`.) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Jun 17, 2025
Rollup merge of #141946 - xizheyin:141933, r=jhpratt std: refactor explanation of `NonNull` Fixes #141933 I cut out the excessive explanation and used an example to explain how to maintain invariance, but I think what is quoted in the *rust reference* in the document needs to be added with a more layman's explanation and example. (I'm not sure if I deleted too much) r? `@workingjubilee`
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Jun 18, 2025
Rollup of 13 pull requests Successful merges: - rust-lang/rust#138538 (Make performance description of String::{insert,insert_str,remove} more precise) - rust-lang/rust#141946 (std: refactor explanation of `NonNull`) - rust-lang/rust#142216 (Miscellaneous RefCell cleanups) - rust-lang/rust#142542 (Manually invalidate caches in SimplifyCfg.) - rust-lang/rust#142563 (Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism) - rust-lang/rust#142570 (Reject union default field values) - rust-lang/rust#142584 (Handle same-crate macro for borrowck semicolon suggestion) - rust-lang/rust#142585 (Update books) - rust-lang/rust#142586 (Fold unnecessary `visit_struct_field_def` in AstValidator) - rust-lang/rust#142587 (Make sure to propagate result from `visit_expr_fields`) - rust-lang/rust#142595 (Revert overeager warning for misuse of `--print native-static-libs`) - rust-lang/rust#142598 (Set elf e_flags on ppc64 targets according to abi) - rust-lang/rust#142601 (Add a comment to `FORMAT_VERSION`.) r? `@ghost` `@rustbot` modify labels: rollup
github-actions bot
pushed a commit
to tautschnig/verify-rust-std
that referenced
this pull request
Jun 24, 2025
std: refactor explanation of `NonNull` Fixes rust-lang#141933 I cut out the excessive explanation and used an example to explain how to maintain invariance, but I think what is quoted in the *rust reference* in the document needs to be added with a more layman's explanation and example. (I'm not sure if I deleted too much) r? `@workingjubilee`
github-actions bot
pushed a commit
to tautschnig/verify-rust-std
that referenced
this pull request
Jun 24, 2025
…kingjubilee Rollup of 13 pull requests Successful merges: - rust-lang#138538 (Make performance description of String::{insert,insert_str,remove} more precise) - rust-lang#141946 (std: refactor explanation of `NonNull`) - rust-lang#142216 (Miscellaneous RefCell cleanups) - rust-lang#142542 (Manually invalidate caches in SimplifyCfg.) - rust-lang#142563 (Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism) - rust-lang#142570 (Reject union default field values) - rust-lang#142584 (Handle same-crate macro for borrowck semicolon suggestion) - rust-lang#142585 (Update books) - rust-lang#142586 (Fold unnecessary `visit_struct_field_def` in AstValidator) - rust-lang#142587 (Make sure to propagate result from `visit_expr_fields`) - rust-lang#142595 (Revert overeager warning for misuse of `--print native-static-libs`) - rust-lang#142598 (Set elf e_flags on ppc64 targets according to abi) - rust-lang#142601 (Add a comment to `FORMAT_VERSION`.) r? `@ghost` `@rustbot` modify labels: rollup
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.
Fixes #141933
I cut out the excessive explanation and used an example to explain how to maintain invariance, but I think what is quoted in the rust reference in the document needs to be added with a more layman's explanation and example.
(I'm not sure if I deleted too much)
r? @workingjubilee