Skip to content

Commit

Permalink
Add --wrap-unsafe-ops option (rust-lang#2354)
Browse files Browse the repository at this point in the history
This reverts commit e8ffb42 and adds a new `--wrap-unsafe-ops` option as a workaround.
  • Loading branch information
pvdrz authored and LoganBarnett committed Dec 2, 2023
1 parent f05a1a4 commit c454169
Show file tree
Hide file tree
Showing 107 changed files with 1,009 additions and 474 deletions.
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.

* Replace the `name: &str` argument for `ParseCallbacks::add_derives` by
`info: DeriveInfo`.
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.

0 comments on commit c454169

Please sign in to comment.