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

Support unsafe_op_in_unsafe_fn #2063

Closed
ojeda opened this issue Jun 3, 2021 · 4 comments · Fixed by #2266
Closed

Support unsafe_op_in_unsafe_fn #2063

ojeda opened this issue Jun 3, 2021 · 4 comments · Fixed by #2266

Comments

@ojeda
Copy link
Contributor

ojeda commented Jun 3, 2021

Projects wishing to use unsafe_op_in_unsafe_fn can allow the warning when importing the bindings.

However, it would be ideal if bindgen would offer a way (e.g. command-line flag) to generate bindings with unsafe blocks inside unsafe fns as needed.

That way, projects can forbid it globally, and those that just deny it do not need to write the allow themselves.

@emilio
Copy link
Contributor

emilio commented Jun 6, 2021

Seems pretty reasonable.

@simlay
Copy link
Contributor

simlay commented Sep 9, 2022

I think that this could be a good feature but if bindgen able to yield safe fns where it's just wrapping unsafe { ... }, we should consider adding granular support. This could be some kind of metadata file that's got key's of name of the functions and values of dictionary with Unsafe: Y/N and Mutating: Y/N.

As discussed over in madsmtm/objc2#85 (comment), it'd be somewhat similar to Swift's apinotes.

Anyway, should I write an issue describing this?

@pvdrz
Copy link
Contributor

pvdrz commented Sep 10, 2022

Anyway, should I write an issue describing this?

I think this would be better because as far as I understand this issue only is about wrapping bodies of unsafe functions in unsafe blocks so the unsafe_op_in_unsafe_fn warning won't trigger if it's enabled. This doesn't affect in any way safe functions with unsafe blocks inside.

@ojeda
Copy link
Contributor Author

ojeda commented Nov 5, 2022

Thanks for this @pvdrz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants