Skip to content

[function pointers example] Marked the function pointer and exported function as unsafe #171

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

Merged
merged 1 commit into from
Jul 24, 2019

Conversation

danielhenrymantilla
Copy link
Contributor

Although the example was targeted at C FFI, in which case unsafe has no value, one should never forget that these functions can also be called from Rust side. Having both the ffi function and the callback be unsafe is more realistic of there being a raw pointer involved (else the only way to provide such a safe callback from Rust would be if it never dereferenced the thunk parameter).

@Lokathor
Copy link
Contributor

Given how the C abi affects your ability to properly unwind and how it's currently being worked on and all, having a safe C abi function is certainly questionable at best. As I understand it, even calling Rust->Rust using C abi gives you all that unwind trouble.

Good change

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 23, 2019

Do we need this example at all ? It took me a while to go through the whole page on function types, just to be able to understand their layout and validity invariant, and to me it did not feel like the example added much.

Copy link
Contributor

@gnzlbg gnzlbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(FWIW this change LGTM - whether we remove the example or not can be discussed later or somewhere else)

@RalfJung
Copy link
Member

Okay, merging then.

@RalfJung RalfJung merged commit 103a2b5 into rust-lang:master Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants