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

Add --wrap-unsafe-ops option #2354

Merged
merged 6 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/bindgen.yml
Expand Up @@ -89,8 +89,6 @@ 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 @@ -154,6 +154,8 @@
## Added

## Changed
* Only wrap unsafe operations in unsafe blocks if the `--wrap_unsafe_ops`
option is enabled.

## Removed

Expand Down
7 changes: 7 additions & 0 deletions bindgen-cli/options.rs
Expand Up @@ -562,6 +562,9 @@ where
.value_name("override")
.multiple_occurrences(true)
.number_of_values(1),
Arg::new("wrap-unsafe-ops")
.long("wrap-unsafe-ops")
.help("Wrap unsafe operations in unsafe blocks."),
Arg::new("V")
.long("version")
.help("Prints the version, and exits"),
Expand Down Expand Up @@ -1085,5 +1088,9 @@ where
}
}

if matches.is_present("wrap-unsafe-ops") {
builder = builder.wrap_unsafe_ops(true);
}

Ok((builder, output, verbose))
}

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.

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: 3 additions & 5 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: 9 additions & 15 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: 9 additions & 15 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.