Skip to content

Commit

Permalink
Wrap unsafe function's bodies in unsafe blocks (rust-lang#2266)
Browse files Browse the repository at this point in the history
This guarantees that bindings generated by `bindgen` compile even if the `unsafe_op_in_unsafe_fn` lint is denied.
  • Loading branch information
pvdrz authored and LoganBarnett committed Dec 2, 2023
1 parent 53d2088 commit 4b06a10
Show file tree
Hide file tree
Showing 94 changed files with 401 additions and 327 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/bindgen.yml
Expand Up @@ -89,6 +89,8 @@ jobs:

- name: Test expectations
run: cd bindgen-tests/tests/expectations && cargo test
env:
RUSTFLAGS: "-D unsafe_op_in_unsafe_fn -D unused_unsafe"

test:
runs-on: ${{matrix.os}}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -160,6 +160,8 @@
* the `ParseCallbacks`trait does not require to implement `UnwindSafe`.
* the `Builder::parse_callbacks` method no longer overwrites previously added
callbacks and composes them in a last-to-first manner.
* any generated rust code containing unsafe operations inside unsafe functions
is wrapped in unsafe blocks now.

## Removed

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindgen-tests/tests/expectations/tests/allowlist-file.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bindgen-tests/tests/expectations/tests/anon_union_1_0.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions bindgen-tests/tests/expectations/tests/class.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions bindgen-tests/tests/expectations/tests/class_1_0.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions bindgen-tests/tests/expectations/tests/class_with_typedef.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions bindgen-tests/tests/expectations/tests/constructor-tp.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions bindgen-tests/tests/expectations/tests/constructors.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions bindgen-tests/tests/expectations/tests/constructors_1_33.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions bindgen-tests/tests/expectations/tests/deleted-function.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4b06a10

Please sign in to comment.