rust-bindgen
rust-bindgen copied to clipboard
Support `unsafe_op_in_unsafe_fn`
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.
Seems pretty reasonable.
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 https://github.com/madsmtm/objc2/issues/85#issuecomment-1236222148, it'd be somewhat similar to Swift's apinotes.
Anyway, should I write an issue describing this?
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.
Thanks for this @pvdrz!