-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Expand function pointer docs #75477
Expand function pointer docs #75477
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Thanks Ralf for document it. Also are you interested in writing this part in Reference? |
Do you think the reference should repeat the same information? That seems a bit strange... |
I don't know if function items and function pointer concepts belong to language or just Rust implementation. |
I don't think that the documentation added in this PR belongs in the reference, though ideally we'd eventually document the rules on when coercion takes place and what kinds of coercion exist. I don't think we need to do that now, though. r=me with commits squashed |
I mean, this is not implementation-specific, it is a general Rust thing. But then so is much of what is documented in the standard library. |
@bors r=Mark-Simulacrum rollup |
📌 Commit 47739bb481ca43e565cf13cbe7990c9fbfc1bcd4 has been approved by |
library/std/src/primitive_docs.rs
Outdated
/// function pointer. Rather, it denotes a value of an unnameable zero-sized | ||
/// type that uniquely identifies the function `bar`. This type *coerces* to a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we mention that function item value doesn't store actual function pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? It is a zero-sized type; it cannot store anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean to make it clear and to confirm that function item doesn't contain function pointer.
Otherwise peple may think that *&bar
will deref to function pointer.
@LukasKalbertodt has a related answer on stackoverflow: https://stackoverflow.com/a/54629954/5456794
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is fine as-is, but you are of course welcome to submit follow-up PRs with specific language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like some of the wording in that post and will try to incorporate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RalfJung In case with "that post" you are talking about my StackOverflow answer, note that it is licensed as CC0 (which I also state on my profile). So feel free to copy whatever you want. Just FYI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LukasKalbertodt that's great, thanks! I am not sure if individual sentences are copyrighted but this means I do not have to worry. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; @Mark-Simulacrum please check.
@bors r- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me when squashed
@bors r=Mark-Simulacrum rollup |
📌 Commit 2338903 has been approved by |
Rollup of 12 pull requests Successful merges: - rust-lang#74650 (Correctly parse `{} && false` in tail expression) - rust-lang#75319 (Fix ICE rust-lang#75307 in `format`) - rust-lang#75417 (Don't spill operands onto the stack in naked functions) - rust-lang#75452 (self-profile: Cache more query key strings when doing self-profiling.) - rust-lang#75459 (fix LocalInfo doc comment) - rust-lang#75462 (Remove unused tcx parameter) - rust-lang#75467 (Fix E0741 error code explanation) - rust-lang#75471 (Change registered "program name" for -Cllvm-args usage messages) - rust-lang#75477 (Expand function pointer docs) - rust-lang#75479 (make rustc-docs component available to rustup) - rust-lang#75496 (Prioritization WG: Open Zulip topics only for `I-prioritize` issues) - rust-lang#75500 (Disable zlib in LLVM on aarch64-apple-darwin) Failed merges: r? @ghost
Be more explicit in the ABI section, and add a section on how to obtain a function pointer, which can be somewhat confusing.
Cc #75239