Skip to content

Commit 046d6f9

Browse files
authored
Add --wrap-unsafe-ops option (#2354)
This reverts commit e8ffb42 and adds a new `--wrap-unsafe-ops` option as a workaround.
1 parent f160d11 commit 046d6f9

File tree

107 files changed

+1009
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1009
-474
lines changed

.github/workflows/bindgen.yml

-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ jobs:
8989

9090
- name: Test expectations
9191
run: cd bindgen-tests/tests/expectations && cargo test
92-
env:
93-
RUSTFLAGS: "-D unsafe_op_in_unsafe_fn -D unused_unsafe"
9492

9593
test:
9694
runs-on: ${{matrix.os}}

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
## Added
155155

156156
## Changed
157+
* Only wrap unsafe operations in unsafe blocks if the `--wrap_unsafe_ops`
158+
option is enabled.
157159

158160
* Replace the `name: &str` argument for `ParseCallbacks::add_derives` by
159161
`info: DeriveInfo`.

bindgen-cli/options.rs

+7
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ where
562562
.value_name("override")
563563
.multiple_occurrences(true)
564564
.number_of_values(1),
565+
Arg::new("wrap-unsafe-ops")
566+
.long("wrap-unsafe-ops")
567+
.help("Wrap unsafe operations in unsafe blocks."),
565568
Arg::new("V")
566569
.long("version")
567570
.help("Prints the version, and exits"),
@@ -1085,5 +1088,9 @@ where
10851088
}
10861089
}
10871090

1091+
if matches.is_present("wrap-unsafe-ops") {
1092+
builder = builder.wrap_unsafe_ops(true);
1093+
}
1094+
10881095
Ok((builder, output, verbose))
10891096
}

bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/allowlist-file.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/anon_union_1_0.rs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/blocklist-methods.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/class.rs

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/class_1_0.rs

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/class_with_typedef.rs

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/constructor-tp.rs

+3-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/constructors.rs

+9-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/constructors_1_33.rs

+9-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)