Skip to content
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

Merged
merged 1 commit into from
Aug 14, 2020
Merged

Expand function pointer docs #75477

merged 1 commit into from
Aug 14, 2020

Conversation

RalfJung
Copy link
Member

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

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2020
@tesuji
Copy link
Contributor

tesuji commented Aug 13, 2020

Thanks Ralf for document it. Also are you interested in writing this part in Reference?

@RalfJung
Copy link
Member Author

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 can help review such a change.

@tesuji
Copy link
Contributor

tesuji commented Aug 13, 2020

I don't know if function items and function pointer concepts belong to language or just Rust implementation.
If it is the latter, only writing it here is fine.

@Mark-Simulacrum
Copy link
Member

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

@RalfJung
Copy link
Member Author

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.

@RalfJung
Copy link
Member Author

@bors r=Mark-Simulacrum rollup

@bors
Copy link
Contributor

bors commented Aug 13, 2020

📌 Commit 47739bb481ca43e565cf13cbe7990c9fbfc1bcd4 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2020
Comment on lines 1129 to 1130
/// function pointer. Rather, it denotes a value of an unnameable zero-sized
/// type that uniquely identifies the function `bar`. This type *coerces* to a
Copy link
Contributor

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?

Copy link
Member

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?

Copy link
Contributor

@tesuji tesuji Aug 13, 2020

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

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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.

@RalfJung
Copy link
Member Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 13, 2020
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a 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

@RalfJung
Copy link
Member Author

@bors r=Mark-Simulacrum rollup

@bors
Copy link
Contributor

bors commented Aug 13, 2020

📌 Commit 2338903 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2020
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
@bors bors merged commit 33fca5a into rust-lang:master Aug 14, 2020
@RalfJung RalfJung deleted the fn-ptrs branch August 14, 2020 06:11
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants