-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rephrase docs in for ptr #66379
Rephrase docs in for ptr #66379
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
r? @RalfJung |
I think that's what the sentence was saying before, no?
|
Oh, yeah, right. I would still advise you to change the wording, it's really easy to misread is as it is |
What do you think? |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Also, could you guys please clarify what " dereferencable for the whole size of |
In an Raw pointers must point to valid data when you dereference them, it's up to the programmer to ensure that they are dereferencable at that point in time. |
Dereferencable isn't a syntactic property, it says whether the pointer actually points to some allocated memory. Like,
That's like saying "every car can fly, i.e., we can throw it out of an airplane". ;) |
More seriously though, we define "dereferencable" at https://doc.rust-lang.org/nightly/core/ptr/index.html. @CreepySkeleton does that help? Maybe the docs here should link there? |
Given that these return references, we should probably also mention something about aliasing? For |
This comment has been minimized.
This comment has been minimized.
But "it points to an initialized instance of
|
Fair.
That's not correct. "dereferencable" is a technical term and just means the memory is allocated; on its own it does not say anything about the data there being initialized or so. |
I think the reason "dereferencable" is listed separately is that the validity part is explicitly called out as "speculative", while dereferencable is not speculative at all. Maybe we should just remove that remark, and just say something like
|
@RalfJung Could you please explain term "speculative"? |
This is UB because we want to be conservative, and if we allow it now we can never make it UB in the future. At rust-lang/unsafe-code-guidelines#77 we are discussing if, long-term, we really want this to be UB. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@CreepySkeleton could you rebase and try using intra-doc links? I guess the target would be |
Should be good now. :3 |
Indeed CI is finally happy. :) @bors r+ rollup+ |
📌 Commit f11dd32 has been approved by |
Rephrase docs in for ptr These methods can be supplied with NULL just fine, this is the whole point of `Option<&T>` return type.
Rephrase docs in for ptr These methods can be supplied with NULL just fine, this is the whole point of `Option<&T>` return type.
Rollup of 11 pull requests Successful merges: - #66379 (Rephrase docs in for ptr) - #66589 (Draw vertical lines correctly in compiler error messages) - #66613 (Allow customising ty::TraitRef's printing behavior) - #66766 (Panic machinery comments and tweaks) - #66791 (Handle GlobalCtxt directly from librustc_interface query system) - #66793 (Record temporary static references in generator witnesses) - #66808 (Cleanup error code) - #66826 (Clarifies how to tag users for assigning PRs) - #66837 (Clarify `{f32,f64}::EPSILON` docs) - #66844 (Miri: do not consider memory allocated by caller_location leaked) - #66872 (Minor documentation fix) Failed merges: r? @ghost
Apply rust-lang#66379 to `*mut T` `as_ref` rust-lang#66379 changed the documentation of `as_ref` on the type `*const T` and `as_mut` on the type `*mut T`, but it missed making that same change for `as_ref` on the type `*mut T`.
Apply rust-lang#66379 to `*mut T` `as_ref` rust-lang#66379 changed the documentation of `as_ref` on the type `*const T` and `as_mut` on the type `*mut T`, but it missed making that same change for `as_ref` on the type `*mut T`.
…arth Rollup of 9 pull requests Successful merges: - rust-lang#73655 (va_args implementation for AAPCS.) - rust-lang#73893 (Stabilize control-flow-guard codegen option) - rust-lang#74237 (compiletest: Rewrite extract_*_version functions) - rust-lang#74454 (small coherence cleanup) - rust-lang#74528 (refactor and reword intra-doc link errors) - rust-lang#74568 (Apply rust-lang#66379 to `*mut T` `as_ref`) - rust-lang#74570 (Use forge links for prioritization procedure) - rust-lang#74589 (Update books) - rust-lang#74635 (Fix tooltip position if the documentation starts with a code block) Failed merges: r? @ghost
These methods can be supplied with NULL just fine, this is the whole point of
Option<&T>
return type.