summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/bindgen.yml2
-rw-r--r--CHANGELOG.md2
-rw-r--r--bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/allowlist-file.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/anon_union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs6
-rw-r--r--bindgen-tests/tests/expectations/tests/class.rs12
-rw-r--r--bindgen-tests/tests/expectations/tests/class_1_0.rs16
-rw-r--r--bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/class_with_typedef.rs8
-rw-r--r--bindgen-tests/tests/expectations/tests/constructor-tp.rs8
-rw-r--r--bindgen-tests/tests/expectations/tests/constructors.rs24
-rw-r--r--bindgen-tests/tests/expectations/tests/constructors_1_33.rs24
-rw-r--r--bindgen-tests/tests/expectations/tests/deleted-function.rs12
-rw-r--r--bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs6
-rw-r--r--bindgen-tests/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/disable-untagged-union.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs10
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs14
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs18
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs14
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs16
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs26
-rw-r--r--bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs24
-rw-r--r--bindgen-tests/tests/expectations/tests/gen-constructors.rs8
-rw-r--r--bindgen-tests/tests/expectations/tests/gen-destructors.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/generate-inline.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/incomplete-array-padding.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-2019.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-410.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-447.rs14
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-493.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-493_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-643-inner-struct.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs10
-rw-r--r--bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/layout_align.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/layout_large_align_field.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-5/objc_template.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/class.rs12
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs16
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/derive-hash-struct-with-incomplete-array.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/incomplete-array-padding.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/issue-643-inner-struct.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/layout_align.rs104
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/objc_template.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/libclang-9/zero-sized-array.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/method-mangling.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_allowlist.rs8
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_blocklist.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_category.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_class.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_class_method.rs14
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_method.rs18
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_method_clash.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_pointer_return_types.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/objc_property_fnptr.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/parm-union.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/public-dtor.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/transform-op.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/typeref_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_dtor.rs2
-rw-r--r--bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs6
-rw-r--r--bindgen-tests/tests/expectations/tests/union_fields_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_template_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/use-core_1_0.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/var-tracing.rs8
-rw-r--r--bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs8
-rw-r--r--bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/zero-size-array-align.rs4
-rw-r--r--bindgen-tests/tests/expectations/tests/zero-sized-array.rs4
-rw-r--r--bindgen/codegen/dyngen.rs12
-rw-r--r--bindgen/codegen/mod.rs24
94 files changed, 401 insertions, 327 deletions
diff --git a/.github/workflows/bindgen.yml b/.github/workflows/bindgen.yml
index bc8477d5..f292d001 100644
--- a/.github/workflows/bindgen.yml
+++ b/.github/workflows/bindgen.yml
@@ -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}}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f559a3f..506878c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs b/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs
index 369e2c75..ac6beee1 100644
--- a/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/allowlist-file.rs b/bindgen-tests/tests/expectations/tests/allowlist-file.rs
index 3b72fb75..db35c226 100644
--- a/bindgen-tests/tests/expectations/tests/allowlist-file.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlist-file.rs
@@ -41,7 +41,7 @@ extern "C" {
impl someClass {
#[inline]
pub unsafe fn somePublicMethod(&mut self, foo: ::std::os::raw::c_int) {
- someClass_somePublicMethod(self, foo)
+ unsafe { someClass_somePublicMethod(self, foo) }
}
}
extern "C" {
diff --git a/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs b/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs
index cbc5ac9b..782ebdb4 100644
--- a/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs
index 63273e60..ea6456bd 100644
--- a/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs
index 12d5eab0..f60d564a 100644
--- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs
+++ b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs
@@ -38,7 +38,7 @@ impl Foo {
&mut self,
arg1: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- Foo_foo(self, arg1)
+ unsafe { Foo_foo(self, arg1) }
}
}
extern "C" {
diff --git a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs
index d860acd1..317d5229 100644
--- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs
+++ b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs
@@ -36,7 +36,7 @@ impl Foo {
&mut self,
arg1: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- Foo_foo(self, arg1)
+ unsafe { Foo_foo(self, arg1) }
}
}
extern "C" {
diff --git a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs
index d860acd1..317d5229 100644
--- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs
+++ b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_pre_1_27.rs
@@ -36,7 +36,7 @@ impl Foo {
&mut self,
arg1: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- Foo_foo(self, arg1)
+ unsafe { Foo_foo(self, arg1) }
}
}
extern "C" {
diff --git a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
index 8a091cb5..e143e415 100644
--- a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
+++ b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
@@ -16,11 +16,11 @@ pub mod root {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs b/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs
index e9c1a76d..91efa9b9 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs
@@ -151,14 +151,14 @@ impl Foo {
}
#[inline]
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_char {
- Foo_type(self)
+ unsafe { Foo_type(self) }
}
#[inline]
pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_char) {
- Foo_set_type_(self, c)
+ unsafe { Foo_set_type_(self, c) }
}
#[inline]
pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_char) {
- Foo_set_type(self, c)
+ unsafe { Foo_set_type(self, c) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/class.rs b/bindgen-tests/tests/expectations/tests/class.rs
index 8542135b..9b2158fe 100644
--- a/bindgen-tests/tests/expectations/tests/class.rs
+++ b/bindgen-tests/tests/expectations/tests/class.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
@@ -490,18 +490,18 @@ extern "C" {
impl RealAbstractionWithTonsOfMethods {
#[inline]
pub unsafe fn bar(&self) {
- RealAbstractionWithTonsOfMethods_bar(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar(self) }
}
#[inline]
pub unsafe fn bar1(&mut self) {
- RealAbstractionWithTonsOfMethods_bar1(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar1(self) }
}
#[inline]
pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) {
- RealAbstractionWithTonsOfMethods_bar2(self, foo)
+ unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) }
}
#[inline]
pub unsafe fn sta() {
- RealAbstractionWithTonsOfMethods_sta()
+ unsafe { RealAbstractionWithTonsOfMethods_sta() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/class_1_0.rs b/bindgen-tests/tests/expectations/tests/class_1_0.rs
index f6c3021e..5163bae9 100644
--- a/bindgen-tests/tests/expectations/tests/class_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/class_1_0.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
@@ -44,11 +44,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
@@ -541,18 +541,18 @@ impl Clone for RealAbstractionWithTonsOfMethods {
impl RealAbstractionWithTonsOfMethods {
#[inline]
pub unsafe fn bar(&self) {
- RealAbstractionWithTonsOfMethods_bar(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar(self) }
}
#[inline]
pub unsafe fn bar1(&mut self) {
- RealAbstractionWithTonsOfMethods_bar1(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar1(self) }
}
#[inline]
pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) {
- RealAbstractionWithTonsOfMethods_bar2(self, foo)
+ unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) }
}
#[inline]
pub unsafe fn sta() {
- RealAbstractionWithTonsOfMethods_sta()
+ unsafe { RealAbstractionWithTonsOfMethods_sta() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs
index 42656079..cf2122c6 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs
index 65e86b27..033b0c3c 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs
@@ -93,19 +93,19 @@ impl Default for C {
impl C {
#[inline]
pub unsafe fn method(&mut self, c: C_MyInt) {
- C_method(self, c)
+ unsafe { C_method(self, c) }
}
#[inline]
pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) {
- C_methodRef(self, c)
+ unsafe { C_methodRef(self, c) }
}
#[inline]
pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) {
- C_complexMethodRef(self, c)
+ unsafe { C_complexMethodRef(self, c) }
}
#[inline]
pub unsafe fn anotherMethod(&mut self, c: AnotherInt) {
- C_anotherMethod(self, c)
+ unsafe { C_anotherMethod(self, c) }
}
}
#[repr(C)]
diff --git a/bindgen-tests/tests/expectations/tests/constructor-tp.rs b/bindgen-tests/tests/expectations/tests/constructor-tp.rs
index 4b339dc3..35c096d7 100644
--- a/bindgen-tests/tests/expectations/tests/constructor-tp.rs
+++ b/bindgen-tests/tests/expectations/tests/constructor-tp.rs
@@ -35,8 +35,10 @@ extern "C" {
impl Bar {
#[inline]
pub unsafe fn new() -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- Bar_Bar(__bindgen_tmp.as_mut_ptr());
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Bar_Bar(__bindgen_tmp.as_mut_ptr());
+ __bindgen_tmp.assume_init()
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/constructors.rs b/bindgen-tests/tests/expectations/tests/constructors.rs
index 2f13effb..615af667 100644
--- a/bindgen-tests/tests/expectations/tests/constructors.rs
+++ b/bindgen-tests/tests/expectations/tests/constructors.rs
@@ -37,15 +37,19 @@ extern "C" {
impl TestOverload {
#[inline]
pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- TestOverload_TestOverload(__bindgen_tmp.as_mut_ptr(), arg1);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ TestOverload_TestOverload(__bindgen_tmp.as_mut_ptr(), arg1);
+ __bindgen_tmp.assume_init()
+ }
}
#[inline]
pub unsafe fn new1(arg1: f64) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- TestOverload_TestOverload1(__bindgen_tmp.as_mut_ptr(), arg1);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ TestOverload_TestOverload1(__bindgen_tmp.as_mut_ptr(), arg1);
+ __bindgen_tmp.assume_init()
+ }
}
}
#[repr(C)]
@@ -73,8 +77,10 @@ extern "C" {
impl TestPublicNoArgs {
#[inline]
pub unsafe fn new() -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- TestPublicNoArgs_TestPublicNoArgs(__bindgen_tmp.as_mut_ptr());
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ TestPublicNoArgs_TestPublicNoArgs(__bindgen_tmp.as_mut_ptr());
+ __bindgen_tmp.assume_init()
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs
index b5d33332..c9818cca 100644
--- a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs
+++ b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs
@@ -39,15 +39,19 @@ extern "C" {
impl TestOverload {
#[inline]
pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- TestOverload_TestOverload(&mut __bindgen_tmp, arg1);
- __bindgen_tmp
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ TestOverload_TestOverload(&mut __bindgen_tmp, arg1);
+ __bindgen_tmp
+ }
}
#[inline]
pub unsafe fn new1(arg1: f64) -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- TestOverload_TestOverload1(&mut __bindgen_tmp, arg1);
- __bindgen_tmp
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ TestOverload_TestOverload1(&mut __bindgen_tmp, arg1);
+ __bindgen_tmp
+ }
}
}
#[repr(C)]
@@ -75,8 +79,10 @@ extern "C" {
impl TestPublicNoArgs {
#[inline]
pub unsafe fn new() -> Self {
- let mut __bindgen_tmp = ::std::mem::uninitialized();
- TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp);
- __bindgen_tmp
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp);
+ __bindgen_tmp
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/deleted-function.rs b/bindgen-tests/tests/expectations/tests/deleted-function.rs
index 96967bb4..69a69618 100644
--- a/bindgen-tests/tests/expectations/tests/deleted-function.rs
+++ b/bindgen-tests/tests/expectations/tests/deleted-function.rs
@@ -34,11 +34,11 @@ extern "C" {
impl A {
#[inline]
pub unsafe fn inline_definition(&mut self) {
- A_inline_definition(self)
+ unsafe { A_inline_definition(self) }
}
#[inline]
pub unsafe fn out_of_line_definition(&mut self) {
- A_out_of_line_definition(self)
+ unsafe { A_out_of_line_definition(self) }
}
}
#[repr(C)]
@@ -84,8 +84,10 @@ extern "C" {
impl C {
#[inline]
pub unsafe fn new(arg1: *mut C) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- C_C(__bindgen_tmp.as_mut_ptr(), arg1);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ C_C(__bindgen_tmp.as_mut_ptr(), arg1);
+ __bindgen_tmp.assume_init()
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs b/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs
index ea6621dd..97a539d9 100644
--- a/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs
@@ -202,14 +202,14 @@ impl Foo {
}
#[inline]
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_char {
- Foo_type(self)
+ unsafe { Foo_type(self) }
}
#[inline]
pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_char) {
- Foo_set_type_(self, c)
+ unsafe { Foo_set_type_(self, c) }
}
#[inline]
pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_char) {
- Foo_set_type(self, c)
+ unsafe { Foo_set_type(self, c) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs b/bindgen-tests/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
index 06c8da1b..067aab36 100644
--- a/bindgen-tests/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs b/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs
index a53b9ba8..604aa28d 100644
--- a/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs b/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs
index 515f496b..78cbe47f 100644
--- a/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs
+++ b/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs
index c834752e..5ad4b23f 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs
@@ -20,7 +20,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -29,8 +29,8 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym)?;
- let baz = __library.get(b"baz\0").map(|sym| *sym)?;
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym)?;
+ let baz = unsafe { __library.get(b"baz\0") }.map(|sym| *sym)?;
Ok(TestLib {
__library,
foo,
@@ -48,9 +48,9 @@ impl TestLib {
x: ::std::os::raw::c_int,
y: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- (self.foo)(x, y)
+ unsafe { (self.foo)(x, y) }
}
pub unsafe fn baz(&self) -> ::std::os::raw::c_int {
- (self.baz)()
+ unsafe { (self.baz)() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs
index e46ffd49..723f44ad 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs
@@ -23,7 +23,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -32,9 +32,9 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym)?;
- let bar = __library.get(b"bar\0").map(|sym| *sym)?;
- let baz = __library.get(b"baz\0").map(|sym| *sym)?;
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym)?;
+ let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym)?;
+ let baz = unsafe { __library.get(b"baz\0") }.map(|sym| *sym)?;
Ok(TestLib {
__library,
foo,
@@ -47,15 +47,15 @@ impl TestLib {
x: ::std::os::raw::c_int,
y: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- (self.foo)(x, y)
+ unsafe { (self.foo)(x, y) }
}
pub unsafe fn bar(
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.bar)(x)
+ unsafe { (self.bar)(x) }
}
pub unsafe fn baz(&self) -> ::std::os::raw::c_int {
- (self.baz)()
+ unsafe { (self.baz)() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs
index cae5bd69..5864ba0a 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs
@@ -32,7 +32,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -41,9 +41,9 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym);
- let bar = __library.get(b"bar\0").map(|sym| *sym);
- let baz = __library.get(b"baz\0").map(|sym| *sym);
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym);
+ let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym);
+ let baz = unsafe { __library.get(b"baz\0") }.map(|sym| *sym);
Ok(TestLib {
__library,
foo,
@@ -56,15 +56,19 @@ impl TestLib {
x: ::std::os::raw::c_int,
y: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- (self.foo.as_ref().expect("Expected function, got error."))(x, y)
+ unsafe {
+ (self.foo.as_ref().expect("Expected function, got error."))(x, y)
+ }
}
pub unsafe fn bar(
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.bar.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.bar.as_ref().expect("Expected function, got error."))(x)
+ }
}
pub unsafe fn baz(&self) -> ::std::os::raw::c_int {
- (self.baz.as_ref().expect("Expected function, got error."))()
+ unsafe { (self.baz.as_ref().expect("Expected function, got error."))() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs
index 06e67ed7..6c9ea274 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs
@@ -20,7 +20,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -29,8 +29,8 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym);
- let foo1 = __library.get(b"foo1\0").map(|sym| *sym);
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym);
+ let foo1 = unsafe { __library.get(b"foo1\0") }.map(|sym| *sym);
Ok(TestLib {
__library,
foo,
@@ -41,9 +41,13 @@ impl TestLib {
&self,
x: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- (self.foo.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.foo.as_ref().expect("Expected function, got error."))(x)
+ }
}
pub unsafe fn foo1(&self, x: f32) -> f32 {
- (self.foo1.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.foo1.as_ref().expect("Expected function, got error."))(x)
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs
index 97bb67ab..c9b24714 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs
@@ -34,7 +34,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -43,9 +43,9 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym);
- let baz = __library.get(b"baz\0").map(|sym| *sym);
- let bazz = __library.get(b"bazz\0").map(|sym| *sym);
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym);
+ let baz = unsafe { __library.get(b"baz\0") }.map(|sym| *sym);
+ let bazz = unsafe { __library.get(b"bazz\0") }.map(|sym| *sym);
Ok(TestLib {
__library,
foo,
@@ -57,12 +57,16 @@ impl TestLib {
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.foo.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.foo.as_ref().expect("Expected function, got error."))(x)
+ }
}
pub unsafe fn baz(
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.baz.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.baz.as_ref().expect("Expected function, got error."))(x)
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs
index af482ad9..30f2be1d 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs
@@ -46,17 +46,19 @@ extern "C" {
impl X {
#[inline]
pub unsafe fn some_function(&mut self) {
- X_some_function(self)
+ unsafe { X_some_function(self) }
}
#[inline]
pub unsafe fn some_other_function(&mut self) {
- X_some_other_function(self)
+ unsafe { X_some_other_function(self) }
}
#[inline]
pub unsafe fn new(x: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- X_X(__bindgen_tmp.as_mut_ptr(), x);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ X_X(__bindgen_tmp.as_mut_ptr(), x);
+ __bindgen_tmp.assume_init()
+ }
}
}
extern crate libloading;
@@ -81,7 +83,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -90,8 +92,8 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym);
- let bar = __library.get(b"bar\0").map(|sym| *sym);
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym);
+ let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym);
Ok(TestLib {
__library,
foo,
@@ -102,12 +104,16 @@ impl TestLib {
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.foo.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.foo.as_ref().expect("Expected function, got error."))(x)
+ }
}
pub unsafe fn bar(
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.bar.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.bar.as_ref().expect("Expected function, got error."))(x)
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs
index 514cff73..d9287518 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs
@@ -46,17 +46,19 @@ extern "C" {
impl A {
#[inline]
pub unsafe fn some_function(&mut self) {
- A_some_function(self)
+ unsafe { A_some_function(self) }
}
#[inline]
pub unsafe fn some_other_function(&mut self) {
- A_some_other_function(self)
+ unsafe { A_some_other_function(self) }
}
#[inline]
pub unsafe fn new(x: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- A_A(__bindgen_tmp.as_mut_ptr(), x);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ A_A(__bindgen_tmp.as_mut_ptr(), x);
+ __bindgen_tmp.assume_init()
+ }
}
}
extern crate libloading;
@@ -76,7 +78,7 @@ impl TestLib {
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe { Self::from_library(library) }
}
pub unsafe fn from_library<L>(
library: L,
@@ -85,8 +87,8 @@ impl TestLib {
L: Into<::libloading::Library>,
{
let __library = library.into();
- let foo = __library.get(b"foo\0").map(|sym| *sym);
- let bar = __library.get(b"bar\0").map(|sym| *sym);
+ let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym);
+ let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym);
Ok(TestLib {
__library,
foo,
@@ -97,9 +99,11 @@ impl TestLib {
&self,
x: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
- (self.foo.as_ref().expect("Expected function, got error."))(x)
+ unsafe {
+ (self.foo.as_ref().expect("Expected function, got error."))(x)
+ }
}
pub unsafe fn bar(&self) -> () {
- (self.bar.as_ref().expect("Expected function, got error."))()
+ unsafe { (self.bar.as_ref().expect("Expected function, got error."))() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/gen-constructors.rs b/bindgen-tests/tests/expectations/tests/gen-constructors.rs
index 89b86379..59af8ef3 100644
--- a/bindgen-tests/tests/expectations/tests/gen-constructors.rs
+++ b/bindgen-tests/tests/expectations/tests/gen-constructors.rs
@@ -30,8 +30,10 @@ extern "C" {
impl Foo {
#[inline]
pub unsafe fn new(a: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- Foo_Foo(__bindgen_tmp.as_mut_ptr(), a);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Foo_Foo(__bindgen_tmp.as_mut_ptr(), a);
+ __bindgen_tmp.assume_init()
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/gen-destructors.rs b/bindgen-tests/tests/expectations/tests/gen-destructors.rs
index 1711f76d..41095209 100644
--- a/bindgen-tests/tests/expectations/tests/gen-destructors.rs
+++ b/bindgen-tests/tests/expectations/tests/gen-destructors.rs
@@ -38,6 +38,6 @@ extern "C" {
impl Foo {
#[inline]
pub unsafe fn destruct(&mut self) {
- Foo_Foo_destructor(self)
+ unsafe { Foo_Foo_destructor(self) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/generate-inline.rs b/bindgen-tests/tests/expectations/tests/generate-inline.rs
index 3cb865a4..9ac66b0f 100644
--- a/bindgen-tests/tests/expectations/tests/generate-inline.rs
+++ b/bindgen-tests/tests/expectations/tests/generate-inline.rs
@@ -30,7 +30,7 @@ extern "C" {
impl Foo {
#[inline]
pub unsafe fn bar() -> ::std::os::raw::c_int {
- Foo_bar()
+ unsafe { Foo_bar() }
}
}
extern "C" {
diff --git a/bindgen-tests/tests/expectations/tests/incomplete-array-padding.rs b/bindgen-tests/tests/expectations/tests/incomplete-array-padding.rs
index 18061ea1..d1ae7ebd 100644
--- a/bindgen-tests/tests/expectations/tests/incomplete-array-padding.rs
+++ b/bindgen-tests/tests/expectations/tests/incomplete-array-padding.rs
@@ -109,11 +109,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/issue-2019.rs b/bindgen-tests/tests/expectations/tests/issue-2019.rs
index 294e9f0e..89f1ac62 100644
--- a/bindgen-tests/tests/expectations/tests/issue-2019.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-2019.rs
@@ -38,7 +38,7 @@ extern "C" {
impl A {
#[inline]
pub unsafe fn make() -> A {
- make()
+ unsafe { make() }
}
}
#[repr(C)]
@@ -74,6 +74,6 @@ extern "C" {
impl B {
#[inline]
pub unsafe fn make() -> B {
- make1()
+ unsafe { make1() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/issue-410.rs b/bindgen-tests/tests/expectations/tests/issue-410.rs
index ad7463c2..739ddf29 100644
--- a/bindgen-tests/tests/expectations/tests/issue-410.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-410.rs
@@ -37,7 +37,7 @@ pub mod root {
impl Value {
#[inline]
pub unsafe fn a(&mut self, arg1: root::JSWhyMagic) {
- Value_a(self, arg1)
+ unsafe { Value_a(self, arg1) }
}
}
}
diff --git a/bindgen-tests/tests/expectations/tests/issue-447.rs b/bindgen-tests/tests/expectations/tests/issue-447.rs
index 949db73b..0a6dd5e6 100644
--- a/bindgen-tests/tests/expectations/tests/issue-447.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-447.rs
@@ -65,12 +65,14 @@ pub mod root {
pub unsafe fn new(
arg1: root::mozilla::detail::GuardObjectNotifier,
) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- JSAutoCompartment_JSAutoCompartment(
- __bindgen_tmp.as_mut_ptr(),
- arg1,
- );
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ JSAutoCompartment_JSAutoCompartment(
+ __bindgen_tmp.as_mut_ptr(),
+ arg1,
+ );
+ __bindgen_tmp.assume_init()
+ }
}
}
}
diff --git a/bindgen-tests/tests/expectations/tests/issue-493.rs b/bindgen-tests/tests/expectations/tests/issue-493.rs
index 61c7f792..019982db 100644
--- a/bindgen-tests/tests/expectations/tests/issue-493.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-493.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs b/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs
index 1a0131c3..12a1e7a2 100644
--- a/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/issue-643-inner-struct.rs b/bindgen-tests/tests/expectations/tests/issue-643-inner-struct.rs
index b69aa16e..03162c4c 100644
--- a/bindgen-tests/tests/expectations/tests/issue-643-inner-struct.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-643-inner-struct.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
index f8869528..dc0b7f08 100644
--- a/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs
@@ -89,13 +89,15 @@ extern "C" {
impl Opaque {
#[inline]
pub unsafe fn eleven_out_of_ten(&mut self) -> SuchWow {
- Opaque_eleven_out_of_ten(self)
+ unsafe { Opaque_eleven_out_of_ten(self) }
}
#[inline]
pub unsafe fn new(pup: Pupper) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- Opaque_Opaque(__bindgen_tmp.as_mut_ptr(), pup);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Opaque_Opaque(__bindgen_tmp.as_mut_ptr(), pup);
+ __bindgen_tmp.assume_init()
+ }
}
}
extern "C" {
diff --git a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
index b4394993..32af443f 100644
--- a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
@@ -100,11 +100,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/layout_align.rs b/bindgen-tests/tests/expectations/tests/layout_align.rs
index 466e7686..718a8024 100644
--- a/bindgen-tests/tests/expectations/tests/layout_align.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_align.rs
@@ -109,11 +109,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
index d7fa0a63..de814146 100644
--- a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
@@ -100,11 +100,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs b/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs
index 075ef46a..f0b312a0 100644
--- a/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
index 90f7ed09..3788d3d0 100644
--- a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
@@ -100,11 +100,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/libclang-5/objc_template.rs b/bindgen-tests/tests/expectations/tests/libclang-5/objc_template.rs
index 53caa661..85ca1601 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-5/objc_template.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-5/objc_template.rs
@@ -30,7 +30,7 @@ pub trait IFoo<ObjectType: 'static>: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, get)
+ unsafe { msg_send!(*self, get) }
}
}
#[repr(transparent)]
@@ -59,6 +59,6 @@ pub trait IFooMultiGeneric<KeyType: 'static, ObjectType: 'static>:
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, objectForKey: key)
+ unsafe { msg_send!(*self, objectForKey: key) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/class.rs b/bindgen-tests/tests/expectations/tests/libclang-9/class.rs
index 0d64a9ff..7d732bb0 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/class.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/class.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
@@ -674,18 +674,18 @@ extern "C" {
impl RealAbstractionWithTonsOfMethods {
#[inline]
pub unsafe fn bar(&self) {
- RealAbstractionWithTonsOfMethods_bar(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar(self) }
}
#[inline]
pub unsafe fn bar1(&mut self) {
- RealAbstractionWithTonsOfMethods_bar1(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar1(self) }
}
#[inline]
pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) {
- RealAbstractionWithTonsOfMethods_bar2(self, foo)
+ unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) }
}
#[inline]
pub unsafe fn sta() {
- RealAbstractionWithTonsOfMethods_sta()
+ unsafe { RealAbstractionWithTonsOfMethods_sta() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs b/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs
index e8c2e077..4364c69a 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
@@ -44,11 +44,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
@@ -725,18 +725,18 @@ impl Clone for RealAbstractionWithTonsOfMethods {
impl RealAbstractionWithTonsOfMethods {
#[inline]
pub unsafe fn bar(&self) {
- RealAbstractionWithTonsOfMethods_bar(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar(self) }
}
#[inline]
pub unsafe fn bar1(&mut self) {
- RealAbstractionWithTonsOfMethods_bar1(self)
+ unsafe { RealAbstractionWithTonsOfMethods_bar1(self) }
}
#[inline]
pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) {
- RealAbstractionWithTonsOfMethods_bar2(self, foo)
+ unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) }
}
#[inline]
pub unsafe fn sta() {
- RealAbstractionWithTonsOfMethods_sta()
+ unsafe { RealAbstractionWithTonsOfMethods_sta() }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/derive-hash-struct-with-incomplete-array.rs b/bindgen-tests/tests/expectations/tests/libclang-9/derive-hash-struct-with-incomplete-array.rs
index 2af22cc4..17154e4d 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/derive-hash-struct-with-incomplete-array.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/derive-hash-struct-with-incomplete-array.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/incomplete-array-padding.rs b/bindgen-tests/tests/expectations/tests/libclang-9/incomplete-array-padding.rs
index 1de963bf..441c3f69 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/incomplete-array-padding.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/incomplete-array-padding.rs
@@ -109,11 +109,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/issue-643-inner-struct.rs b/bindgen-tests/tests/expectations/tests/libclang-9/issue-643-inner-struct.rs
index ab402cfb..4161c6db 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/issue-643-inner-struct.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/issue-643-inner-struct.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/layout_align.rs b/bindgen-tests/tests/expectations/tests/libclang-9/layout_align.rs
index f6a32704..df940912 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/layout_align.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/layout_align.rs
@@ -109,11 +109,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
@@ -151,56 +151,56 @@ fn bindgen_test_layout_rte_kni_fifo() {
concat!("Alignment of ", stringify!(rte_kni_fifo))
);
assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).write) as usize - ptr as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_kni_fifo),
- "::",
- stringify!(write)
- )
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).read) as usize - ptr as usize },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_kni_fifo),
- "::",
- stringify!(read)
- )
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_kni_fifo),
- "::",
- stringify!(len)
- )
- );
- assert_eq!(
- unsafe {
- ::std::ptr::addr_of!((*ptr).elem_size) as usize - ptr as usize
- },
- 12usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_kni_fifo),
- "::",
- stringify!(elem_size)
- )
- );
- assert_eq!(
- unsafe { ::std::ptr::addr_of!((*ptr).buffer) as usize - ptr as usize },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_kni_fifo),
- "::",
- stringify!(buffer)
- )
+ unsafe { ::std::ptr::addr_of!((*ptr).write) as usize - ptr as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_kni_fifo),
+ "::",
+ stringify!(write)
+ )
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).read) as usize - ptr as usize },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_kni_fifo),
+ "::",
+ stringify!(read)
+ )
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize },
+ 8usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_kni_fifo),
+ "::",
+ stringify!(len)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ ::std::ptr::addr_of!((*ptr).elem_size) as usize - ptr as usize
+ },
+ 12usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_kni_fifo),
+ "::",
+ stringify!(elem_size)
+ )
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).buffer) as usize - ptr as usize },
+ 16usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_kni_fifo),
+ "::",
+ stringify!(buffer)
+ )
);
}
impl Default for rte_kni_fifo {
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/objc_template.rs b/bindgen-tests/tests/expectations/tests/libclang-9/objc_template.rs
index 3c615035..90d9d993 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/objc_template.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/objc_template.rs
@@ -30,7 +30,7 @@ pub trait IFoo<ObjectType: 'static>: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, get)
+ unsafe { msg_send!(*self, get) }
}
}
#[repr(transparent)]
@@ -59,6 +59,6 @@ pub trait IFooMultiGeneric<KeyType: 'static, ObjectType: 'static>:
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, objectForKey: key)
+ unsafe { msg_send!(*self, objectForKey: key) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/zero-sized-array.rs b/bindgen-tests/tests/expectations/tests/libclang-9/zero-sized-array.rs
index 3066fac4..71a2d6d6 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/zero-sized-array.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/zero-sized-array.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/method-mangling.rs b/bindgen-tests/tests/expectations/tests/method-mangling.rs
index e4627ac8..5f8a8474 100644
--- a/bindgen-tests/tests/expectations/tests/method-mangling.rs
+++ b/bindgen-tests/tests/expectations/tests/method-mangling.rs
@@ -30,6 +30,6 @@ extern "C" {
impl Foo {
#[inline]
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int {
- Foo_type(self)
+ unsafe { Foo_type(self) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_allowlist.rs b/bindgen-tests/tests/expectations/tests/objc_allowlist.rs
index 370cab93..76971a5f 100644
--- a/bindgen-tests/tests/expectations/tests/objc_allowlist.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_allowlist.rs
@@ -14,13 +14,13 @@ pub trait PSomeProtocol: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, protocolMethod)
+ unsafe { msg_send!(*self, protocolMethod) }
}
unsafe fn protocolClassMethod()
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(SomeProtocol), protocolClassMethod)
+ unsafe { msg_send!(class!(SomeProtocol), protocolClassMethod) }
}
}
#[repr(transparent)]
@@ -45,13 +45,13 @@ pub trait IAllowlistMe: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, method)
+ unsafe { msg_send!(*self, method) }
}
unsafe fn classMethod()
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(AllowlistMe), classMethod)
+ unsafe { msg_send!(class!(AllowlistMe), classMethod) }
}
}
impl AllowlistMe_InterestingCategory for AllowlistMe {}
diff --git a/bindgen-tests/tests/expectations/tests/objc_blocklist.rs b/bindgen-tests/tests/expectations/tests/objc_blocklist.rs
index 7d5d19b0..f16eb0f9 100644
--- a/bindgen-tests/tests/expectations/tests/objc_blocklist.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_blocklist.rs
@@ -31,12 +31,12 @@ pub trait ISomeClass: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, ambiguouslyBlockedMethod)
+ unsafe { msg_send!(*self, ambiguouslyBlockedMethod) }
}
unsafe fn instanceMethod(&self)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, instanceMethod)
+ unsafe { msg_send!(*self, instanceMethod) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_category.rs b/bindgen-tests/tests/expectations/tests/objc_category.rs
index 9d60233b..f05c2bbd 100644
--- a/bindgen-tests/tests/expectations/tests/objc_category.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_category.rs
@@ -30,7 +30,7 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, method)
+ unsafe { msg_send!(*self, method) }
}
}
impl Foo_BarCategory for Foo {}
@@ -39,6 +39,6 @@ pub trait Foo_BarCategory: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, categoryMethod)
+ unsafe { msg_send!(*self, categoryMethod) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_class.rs b/bindgen-tests/tests/expectations/tests/objc_class.rs
index b322bddc..0fe8e254 100644
--- a/bindgen-tests/tests/expectations/tests/objc_class.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_class.rs
@@ -33,6 +33,6 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, method)
+ unsafe { msg_send!(*self, method) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_class_method.rs b/bindgen-tests/tests/expectations/tests/objc_class_method.rs
index 29e70256..796698d2 100644
--- a/bindgen-tests/tests/expectations/tests/objc_class_method.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_class_method.rs
@@ -30,31 +30,31 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), method)
+ unsafe { msg_send!(class!(Foo), method) }
}
unsafe fn methodWithInt_(foo: ::std::os::raw::c_int)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), methodWithInt: foo)
+ unsafe { msg_send!(class!(Foo), methodWithInt: foo) }
}
unsafe fn methodWithFoo_(foo: Foo)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), methodWithFoo: foo)
+ unsafe { msg_send!(class!(Foo), methodWithFoo: foo) }
}
unsafe fn methodReturningInt() -> ::std::os::raw::c_int
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), methodReturningInt)
+ unsafe { msg_send!(class!(Foo), methodReturningInt) }
}
unsafe fn methodReturningFoo() -> Foo
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), methodReturningFoo)
+ unsafe { msg_send!(class!(Foo), methodReturningFoo) }
}
unsafe fn methodWithArg1_andArg2_andArg3_(
intvalue: ::std::os::raw::c_int,
@@ -63,6 +63,8 @@ pub trait IFoo: Sized + std::ops::Deref {
) where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send ! (class ! (Foo) , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue)
+ unsafe {
+ msg_send ! (class ! (Foo) , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue)
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_method.rs b/bindgen-tests/tests/expectations/tests/objc_method.rs
index 593fd277..8962413e 100644
--- a/bindgen-tests/tests/expectations/tests/objc_method.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_method.rs
@@ -30,31 +30,31 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, method)
+ unsafe { msg_send!(*self, method) }
}
unsafe fn methodWithInt_(&self, foo: ::std::os::raw::c_int)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, methodWithInt: foo)
+ unsafe { msg_send!(*self, methodWithInt: foo) }
}
unsafe fn methodWithFoo_(&self, foo: Foo)
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, methodWithFoo: foo)
+ unsafe { msg_send!(*self, methodWithFoo: foo) }
}
unsafe fn methodReturningInt(&self) -> ::std::os::raw::c_int
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, methodReturningInt)
+ unsafe { msg_send!(*self, methodReturningInt) }
}
unsafe fn methodReturningFoo(&self) -> Foo
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, methodReturningFoo)
+ unsafe { msg_send!(*self, methodReturningFoo) }
}
unsafe fn methodWithArg1_andArg2_andArg3_(
&self,
@@ -64,7 +64,9 @@ pub trait IFoo: Sized + std::ops::Deref {
) where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send ! (* self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue)
+ unsafe {
+ msg_send ! (* self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue)
+ }
}
unsafe fn methodWithAndWithoutKeywords_arg2Name__arg4Name_(
&self,
@@ -76,7 +78,9 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send ! (* self , methodWithAndWithoutKeywords : arg1 arg2Name : arg2 arg3 : arg3 arg4Name : arg4)
+ unsafe {
+ msg_send ! (* self , methodWithAndWithoutKeywords : arg1 arg2Name : arg2 arg3 : arg3 arg4Name : arg4)
+ }
}
}
pub type instancetype = id;
diff --git a/bindgen-tests/tests/expectations/tests/objc_method_clash.rs b/bindgen-tests/tests/expectations/tests/objc_method_clash.rs
index ac77cc19..bd2df7d0 100644
--- a/bindgen-tests/tests/expectations/tests/objc_method_clash.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_method_clash.rs
@@ -30,12 +30,12 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, foo)
+ unsafe { msg_send!(*self, foo) }
}
unsafe fn class_foo()
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), foo)
+ unsafe { msg_send!(class!(Foo), foo) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_pointer_return_types.rs b/bindgen-tests/tests/expectations/tests/objc_pointer_return_types.rs
index 1ec8494d..d49f17c1 100644
--- a/bindgen-tests/tests/expectations/tests/objc_pointer_return_types.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_pointer_return_types.rs
@@ -47,12 +47,12 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, methodUsingBar: my_bar)
+ unsafe { msg_send!(*self, methodUsingBar: my_bar) }
}
unsafe fn methodReturningBar() -> Bar
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(class!(Foo), methodReturningBar)
+ unsafe { msg_send!(class!(Foo), methodReturningBar) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/objc_property_fnptr.rs b/bindgen-tests/tests/expectations/tests/objc_property_fnptr.rs
index 9f3fabd2..90a3dc8d 100644
--- a/bindgen-tests/tests/expectations/tests/objc_property_fnptr.rs
+++ b/bindgen-tests/tests/expectations/tests/objc_property_fnptr.rs
@@ -38,7 +38,7 @@ pub trait IFoo: Sized + std::ops::Deref {
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, func)
+ unsafe { msg_send!(*self, func) }
}
unsafe fn setFunc_(
&self,
@@ -52,6 +52,6 @@ pub trait IFoo: Sized + std::ops::Deref {
) where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(*self, setFunc: func)
+ unsafe { msg_send!(*self, setFunc: func) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/parm-union.rs b/bindgen-tests/tests/expectations/tests/parm-union.rs
index 9f7dd20a..4738b301 100644
--- a/bindgen-tests/tests/expectations/tests/parm-union.rs
+++ b/bindgen-tests/tests/expectations/tests/parm-union.rs
@@ -30,7 +30,7 @@ extern "C" {
impl Struct {
#[inline]
pub unsafe fn Function(&mut self, arg1: *mut Union) {
- Struct_Function(self, arg1)
+ unsafe { Struct_Function(self, arg1) }
}
}
#[repr(C)]
diff --git a/bindgen-tests/tests/expectations/tests/public-dtor.rs b/bindgen-tests/tests/expectations/tests/public-dtor.rs
index 64a50389..f9559a08 100644
--- a/bindgen-tests/tests/expectations/tests/public-dtor.rs
+++ b/bindgen-tests/tests/expectations/tests/public-dtor.rs
@@ -30,6 +30,6 @@ extern "C" {
impl cv_String {
#[inline]
pub unsafe fn destruct(&mut self) {
- cv_String_String_destructor(self)
+ unsafe { cv_String_String_destructor(self) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs
index 8db33d11..fd4d561b 100644
--- a/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
index 55432d47..52c6904c 100644
--- a/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs
index af795b64..a777adf3 100644
--- a/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/transform-op.rs b/bindgen-tests/tests/expectations/tests/transform-op.rs
index 84a94603..eec37a3d 100644
--- a/bindgen-tests/tests/expectations/tests/transform-op.rs
+++ b/bindgen-tests/tests/expectations/tests/transform-op.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs b/bindgen-tests/tests/expectations/tests/typeref_1_0.rs
index 8e4143c0..3376bf04 100644
--- a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/typeref_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs b/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs
index a057cc34..63e39781 100644
--- a/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs
@@ -16,11 +16,11 @@ pub mod root {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
index 22277468..f15ce0f0 100644
--- a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
@@ -100,11 +100,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_dtor.rs b/bindgen-tests/tests/expectations/tests/union_dtor.rs
index 085e5ca3..cb363de6 100644
--- a/bindgen-tests/tests/expectations/tests/union_dtor.rs
+++ b/bindgen-tests/tests/expectations/tests/union_dtor.rs
@@ -62,6 +62,6 @@ impl Default for UnionWithDtor {
impl UnionWithDtor {
#[inline]
pub unsafe fn destruct(&mut self) {
- UnionWithDtor_UnionWithDtor_destructor(self)
+ unsafe { UnionWithDtor_UnionWithDtor_destructor(self) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs b/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs
index 67455aa8..519bd869 100644
--- a/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
@@ -98,6 +98,6 @@ extern "C" {
impl UnionWithDtor {
#[inline]
pub unsafe fn destruct(&mut self) {
- UnionWithDtor_UnionWithDtor_destructor(self)
+ unsafe { UnionWithDtor_UnionWithDtor_destructor(self) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs b/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs
index b5f94bcd..621a961f 100644
--- a/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_template_1_0.rs b/bindgen-tests/tests/expectations/tests/union_template_1_0.rs
index 487579f7..543f154d 100644
--- a/bindgen-tests/tests/expectations/tests/union_template_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_template_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs
index 8b11e757..316f8453 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
index 6ce6ed22..c06f6489 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
@@ -100,11 +100,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs
index f3e4b840..6c856634 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
index 1562a8c9..d4c6fec9 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
index 197a6bbf..96f03680 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs
index 63b43baa..869720d4 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs
index a1e452fe..4b1ab553 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs b/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs
index 3c500b21..227afaff 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs
@@ -14,11 +14,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::std::mem::transmute(self)
+ unsafe { ::std::mem::transmute(self) }
}
}
impl<T> ::std::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/use-core_1_0.rs b/bindgen-tests/tests/expectations/tests/use-core_1_0.rs
index 8c6d0fd2..0310211d 100644
--- a/bindgen-tests/tests/expectations/tests/use-core_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/use-core_1_0.rs
@@ -16,11 +16,11 @@ impl<T> __BindgenUnionField<T> {
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::core::mem::transmute(self)
+ unsafe { ::core::mem::transmute(self) }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::core::mem::transmute(self)
+ unsafe { ::core::mem::transmute(self) }
}
}
impl<T> ::core::default::Default for __BindgenUnionField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/var-tracing.rs b/bindgen-tests/tests/expectations/tests/var-tracing.rs
index 37fdd951..22e7e6ed 100644
--- a/bindgen-tests/tests/expectations/tests/var-tracing.rs
+++ b/bindgen-tests/tests/expectations/tests/var-tracing.rs
@@ -43,9 +43,11 @@ extern "C" {
impl Bar {
#[inline]
pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- Bar_Bar(__bindgen_tmp.as_mut_ptr(), baz);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Bar_Bar(__bindgen_tmp.as_mut_ptr(), baz);
+ __bindgen_tmp.assume_init()
+ }
}
}
#[repr(C)]
diff --git a/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs b/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs
index 6d15c51f..909d04de 100644
--- a/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs
+++ b/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs
@@ -33,8 +33,10 @@ extern "C" {
impl Foo {
#[inline]
pub unsafe fn new(var: ::std::os::raw::c_int) -> Self {
- let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
- Foo_Foo(__bindgen_tmp.as_mut_ptr(), var);
- __bindgen_tmp.assume_init()
+ unsafe {
+ let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit();
+ Foo_Foo(__bindgen_tmp.as_mut_ptr(), var);
+ __bindgen_tmp.assume_init()
+ }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs b/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs
index 92bb13cc..f144edd4 100644
--- a/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs
+++ b/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs
@@ -39,13 +39,13 @@ extern "thiscall" {
impl Foo {
#[inline]
pub unsafe fn test(&mut self) {
- Foo_test(self)
+ unsafe { Foo_test(self) }
}
#[inline]
pub unsafe fn test2(
&mut self,
var: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
- Foo_test2(self, var)
+ unsafe { Foo_test2(self, var) }
}
}
diff --git a/bindgen-tests/tests/expectations/tests/zero-size-array-align.rs b/bindgen-tests/tests/expectations/tests/zero-size-array-align.rs
index d7d0f661..e99abb87 100644
--- a/bindgen-tests/tests/expectations/tests/zero-size-array-align.rs
+++ b/bindgen-tests/tests/expectations/tests/zero-size-array-align.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen-tests/tests/expectations/tests/zero-sized-array.rs b/bindgen-tests/tests/expectations/tests/zero-sized-array.rs
index 4ba52498..27c48f0e 100644
--- a/bindgen-tests/tests/expectations/tests/zero-sized-array.rs
+++ b/bindgen-tests/tests/expectations/tests/zero-sized-array.rs
@@ -23,11 +23,11 @@ impl<T> __IncompleteArrayField<T> {
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::std::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) }
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
diff --git a/bindgen/codegen/dyngen.rs b/bindgen/codegen/dyngen.rs
index d02c51e4..f310f14e 100644
--- a/bindgen/codegen/dyngen.rs
+++ b/bindgen/codegen/dyngen.rs
@@ -92,7 +92,9 @@ impl DynamicItems {
) -> Result<Self, ::libloading::Error>
where P: AsRef<::std::ffi::OsStr> {
let library = ::libloading::Library::new(path)?;
- Self::from_library(library)
+ unsafe {
+ Self::from_library(library)
+ }
}
pub unsafe fn from_library<L>(
@@ -157,7 +159,9 @@ impl DynamicItems {
self.struct_implementation.push(quote! {
#(#attributes)*
pub unsafe fn #ident ( &self, #( #args ),* ) -> #ret_ty {
- #call_body
+ unsafe {
+ #call_body
+ }
}
});
}
@@ -166,11 +170,11 @@ impl DynamicItems {
let ident_str = codegen::helpers::ast_ty::cstr_expr(ident.to_string());
self.constructor_inits.push(if is_required {
quote! {
- let #ident = __library.get(#ident_str).map(|sym| *sym)?;
+ let #ident = unsafe { __library.get(#ident_str) }.map(|sym| *sym)?;
}
} else {
quote! {
- let #ident = __library.get(#ident_str).map(|sym| *sym);
+ let #ident = unsafe { __library.get(#ident_str) }.map(|sym| *sym);
}
});
diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs
index d0c19136..e0d96cd1 100644
--- a/bindgen/codegen/mod.rs
+++ b/bindgen/codegen/mod.rs
@@ -2605,7 +2605,9 @@ impl MethodCodegen for Method {
methods.push(quote! {
#(#attrs)*
pub unsafe fn #name ( #( #args ),* ) #ret {
- #block
+ unsafe {
+ #block
+ }
}
});
}
@@ -4263,7 +4265,9 @@ fn objc_method_codegen(
methods.push(quote! {
unsafe fn #method_name #sig where <Self as std::ops::Deref>::Target: objc::Message + Sized {
- #body
+ unsafe {
+ #body
+ }
}
});
}
@@ -4638,12 +4642,16 @@ pub mod utils {
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::#prefix::mem::transmute(self)
+ unsafe {
+ ::#prefix::mem::transmute(self)
+ }
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::#prefix::mem::transmute(self)
+ unsafe {
+ ::#prefix::mem::transmute(self)
+ }
}
}
};
@@ -4757,12 +4765,16 @@ pub mod utils {
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::#prefix::slice::from_raw_parts(self.as_ptr(), len)
+ unsafe {
+ ::#prefix::slice::from_raw_parts(self.as_ptr(), len)
+ }
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ unsafe {
+ ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ }
}
}
};