-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Subpar documentation for ptr-to-ref conversion methods #124669
Comments
@rustbot claim i'll tackle normalizing the doctests first, since the wording of the pointer methods has implications for unsafe code guidelines. |
…=workingjubilee docs(core): make more const_ptr doctests assert instead of printing improves on rust-lang#124669
…=workingjubilee docs(core): make more const_ptr doctests assert instead of printing improves on rust-lang#124669
…=workingjubilee docs(core): make more const_ptr doctests assert instead of printing improves on rust-lang#124669
Rollup merge of rust-lang#126210 - lolbinarycat:ptr_doctest_assert, r=workingjubilee docs(core): make more const_ptr doctests assert instead of printing improves on rust-lang#124669
@rustbot reopen |
Well, I'm powerless here. @rustbot knows how to close issues, but not how to reopen them. GitHub doesn't let me to reopen it myself. And @bors is very fond of marking issues as completed even when they aren't. #126210 addressed only one of the concerns (I've updated the OP to reflect this), but there's still a lot of work to be done. @workingjubilee could you please help me in this and reopen the issue? Thanks! |
whoops, yeah i should have said "part of" instead of "fixes", since my pr only addresses part of the issue, sorry about that (unfortunately i don't have the permissions to reopen issues either) |
working on deduplicating documentation and it turns out that blurb also got copy-pasted onto several methods on NonNull, and those copies never got updated, so they're actually wrong, not listing the requirment of pointing to a valid value |
I wouldn't say it is "needlessly" scary. The returned lifetime is equivalent to |
My comment was less "it's needlessly scary" and more "it should be clear that if you do not specifically give a lifetime, it will infer any plausible lifetime from context". This does include |
Yes, just like a The current signature of |
…=cuviper deduplicate and clarify rules for converting pointers to references part of rust-lang#124669
…=cuviper deduplicate and clarify rules for converting pointers to references part of rust-lang#124669
Rollup merge of rust-lang#128157 - lolbinarycat:unify-ptr-ref-docs, r=cuviper deduplicate and clarify rules for converting pointers to references part of rust-lang#124669
While trying to merge #122492, some issues with the existing documentation became apparent.
The methods in question
<*const T>::as_ref
<*mut T>::as_ref
<*mut T>::as_mut
<*const T>::as_ref_unchecked
1<*mut T>::as_ref_unchecked
1<*mut T>::as_mut_unchecked
1<*const T>::as_uninit_ref
2<*mut T>::as_uninit_ref
2<*mut T>::as_uninit_mut
2The problems
Documentation
UnsafeCell
Needlessly scary wording around the output's lifetimeOr not?Doctests
Currently, they do printing instead of asserting. This should probably be changed to assertions.(Fixed in docs(core): make more const_ptr doctests assert instead of printing #126210)None
foras_ref
, but no such assertion foras_ref_unchecked
is possible.)Moving forward
Feel free to voice your opinions/wishes/suggestions/questions regarding this issue or to submit PRs addressing any of the problems above (not necessarily all at once). Also, doctests can probably be worked on independently from the documentation itself.
Beep-Boop
@rustbot label +A-docs +A-doctests +C-discussion +C-enhancement +E-help-wanted
And now footnotes:
Footnotes
Not yet stabilized (Tracking Issue for raw-pointer-to-reference conversion methods #122034) ↩ ↩2 ↩3
Not yet stabilized (Tracking Issue for pointer methods returning
MaybeUninit<T>
#75402) ↩ ↩2 ↩3The text was updated successfully, but these errors were encountered: