diff --git a/.github/workflows/bindgen.yml b/.github/workflows/bindgen.yml index f292d001aa..bc8477d503 100644 --- a/.github/workflows/bindgen.yml +++ b/.github/workflows/bindgen.yml @@ -89,8 +89,6 @@ jobs: - name: Test expectations run: cd bindgen-tests/tests/expectations && cargo test - env: - RUSTFLAGS: "-D unsafe_op_in_unsafe_fn -D unused_unsafe" test: runs-on: ${{matrix.os}} 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 ac6beee12d..369e2c75ea 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/allowlist-file.rs b/bindgen-tests/tests/expectations/tests/allowlist-file.rs index db35c22654..3b72fb75eb 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) { - unsafe { someClass_somePublicMethod(self, foo) } + 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 782ebdb4bb..cbc5ac9b3f 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 ea6456bd75..63273e608f 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 f60d564a9a..12d5eab04b 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 { - unsafe { Foo_foo(self, arg1) } + 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 317d52297c..d860acd1b4 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 { - unsafe { Foo_foo(self, arg1) } + 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 317d52297c..d860acd1b4 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 { - unsafe { Foo_foo(self, arg1) } + 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 e143e415eb..8a091cb5e2 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 { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 91efa9b9da..e9c1a76d1c 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 { - unsafe { Foo_type(self) } + Foo_type(self) } #[inline] pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_char) { - unsafe { Foo_set_type_(self, c) } + Foo_set_type_(self, c) } #[inline] pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_char) { - unsafe { Foo_set_type(self, c) } + Foo_set_type(self, c) } } diff --git a/bindgen-tests/tests/expectations/tests/blocklist-methods.rs b/bindgen-tests/tests/expectations/tests/blocklist-methods.rs index 5b625f0a4e..eadc0694ed 100644 --- a/bindgen-tests/tests/expectations/tests/blocklist-methods.rs +++ b/bindgen-tests/tests/expectations/tests/blocklist-methods.rs @@ -30,6 +30,6 @@ extern "C" { impl Foo { #[inline] pub unsafe fn foo(&mut self) -> ::std::os::raw::c_int { - unsafe { Foo_foo(self) } + Foo_foo(self) } } diff --git a/bindgen-tests/tests/expectations/tests/class.rs b/bindgen-tests/tests/expectations/tests/class.rs index 9b2158fedb..8542135b07 100644 --- a/bindgen-tests/tests/expectations/tests/class.rs +++ b/bindgen-tests/tests/expectations/tests/class.rs @@ -23,11 +23,11 @@ impl __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { @@ -490,18 +490,18 @@ extern "C" { impl RealAbstractionWithTonsOfMethods { #[inline] pub unsafe fn bar(&self) { - unsafe { RealAbstractionWithTonsOfMethods_bar(self) } + RealAbstractionWithTonsOfMethods_bar(self) } #[inline] pub unsafe fn bar1(&mut self) { - unsafe { RealAbstractionWithTonsOfMethods_bar1(self) } + RealAbstractionWithTonsOfMethods_bar1(self) } #[inline] pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { - unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) } + RealAbstractionWithTonsOfMethods_bar2(self, foo) } #[inline] pub unsafe fn sta() { - unsafe { RealAbstractionWithTonsOfMethods_sta() } + 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 5163bae9be..f6c3021eb3 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { @@ -44,11 +44,11 @@ impl __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { @@ -541,18 +541,18 @@ impl Clone for RealAbstractionWithTonsOfMethods { impl RealAbstractionWithTonsOfMethods { #[inline] pub unsafe fn bar(&self) { - unsafe { RealAbstractionWithTonsOfMethods_bar(self) } + RealAbstractionWithTonsOfMethods_bar(self) } #[inline] pub unsafe fn bar1(&mut self) { - unsafe { RealAbstractionWithTonsOfMethods_bar1(self) } + RealAbstractionWithTonsOfMethods_bar1(self) } #[inline] pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { - unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) } + RealAbstractionWithTonsOfMethods_bar2(self, foo) } #[inline] pub unsafe fn sta() { - unsafe { RealAbstractionWithTonsOfMethods_sta() } + 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 cf2122c625..42656079df 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs index 033b0c3c0b..65e86b2709 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) { - unsafe { C_method(self, c) } + C_method(self, c) } #[inline] pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) { - unsafe { C_methodRef(self, c) } + C_methodRef(self, c) } #[inline] pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) { - unsafe { C_complexMethodRef(self, c) } + C_complexMethodRef(self, c) } #[inline] pub unsafe fn anotherMethod(&mut self, c: AnotherInt) { - unsafe { C_anotherMethod(self, c) } + 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 35c096d704..4b339dc3c4 100644 --- a/bindgen-tests/tests/expectations/tests/constructor-tp.rs +++ b/bindgen-tests/tests/expectations/tests/constructor-tp.rs @@ -35,10 +35,8 @@ extern "C" { impl Bar { #[inline] pub unsafe fn new() -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - Bar_Bar(__bindgen_tmp.as_mut_ptr()); - __bindgen_tmp.assume_init() - } + 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 615af667d0..2f13effbef 100644 --- a/bindgen-tests/tests/expectations/tests/constructors.rs +++ b/bindgen-tests/tests/expectations/tests/constructors.rs @@ -37,19 +37,15 @@ extern "C" { impl TestOverload { #[inline] pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - TestOverload_TestOverload(__bindgen_tmp.as_mut_ptr(), arg1); - __bindgen_tmp.assume_init() - } + 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 { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - TestOverload_TestOverload1(__bindgen_tmp.as_mut_ptr(), arg1); - __bindgen_tmp.assume_init() - } + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + TestOverload_TestOverload1(__bindgen_tmp.as_mut_ptr(), arg1); + __bindgen_tmp.assume_init() } } #[repr(C)] @@ -77,10 +73,8 @@ extern "C" { impl TestPublicNoArgs { #[inline] pub unsafe fn new() -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - TestPublicNoArgs_TestPublicNoArgs(__bindgen_tmp.as_mut_ptr()); - __bindgen_tmp.assume_init() - } + 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 c9818ccaab..b5d333325b 100644 --- a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs +++ b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs @@ -39,19 +39,15 @@ extern "C" { impl TestOverload { #[inline] pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - TestOverload_TestOverload(&mut __bindgen_tmp, arg1); - __bindgen_tmp - } + let mut __bindgen_tmp = ::std::mem::uninitialized(); + TestOverload_TestOverload(&mut __bindgen_tmp, arg1); + __bindgen_tmp } #[inline] pub unsafe fn new1(arg1: f64) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - TestOverload_TestOverload1(&mut __bindgen_tmp, arg1); - __bindgen_tmp - } + let mut __bindgen_tmp = ::std::mem::uninitialized(); + TestOverload_TestOverload1(&mut __bindgen_tmp, arg1); + __bindgen_tmp } } #[repr(C)] @@ -79,10 +75,8 @@ extern "C" { impl TestPublicNoArgs { #[inline] pub unsafe fn new() -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp); - __bindgen_tmp - } + 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 69a6961803..96967bb461 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) { - unsafe { A_inline_definition(self) } + A_inline_definition(self) } #[inline] pub unsafe fn out_of_line_definition(&mut self) { - unsafe { A_out_of_line_definition(self) } + A_out_of_line_definition(self) } } #[repr(C)] @@ -84,10 +84,8 @@ extern "C" { impl C { #[inline] pub unsafe fn new(arg1: *mut C) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - C_C(__bindgen_tmp.as_mut_ptr(), arg1); - __bindgen_tmp.assume_init() - } + 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 97a539d91d..ea6621dd1c 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 { - unsafe { Foo_type(self) } + Foo_type(self) } #[inline] pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_char) { - unsafe { Foo_set_type_(self, c) } + Foo_set_type_(self, c) } #[inline] pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_char) { - unsafe { Foo_set_type(self, c) } + 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 067aab36f8..06c8da1bad 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 604aa28d44..a53b9ba8e6 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs b/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs index 78cbe47fa4..515f496b87 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/duplicated-definition-count.rs b/bindgen-tests/tests/expectations/tests/duplicated-definition-count.rs index 8fdffe56e4..829022a279 100644 --- a/bindgen-tests/tests/expectations/tests/duplicated-definition-count.rs +++ b/bindgen-tests/tests/expectations/tests/duplicated-definition-count.rs @@ -50,7 +50,7 @@ impl BitStream { inputByteArray: *const ::std::os::raw::c_char, numberOfBytes: ::std::os::raw::c_uint, ) { - unsafe { BitStream_Write(self, inputByteArray, numberOfBytes) } + BitStream_Write(self, inputByteArray, numberOfBytes) } #[inline] pub unsafe fn Write1( @@ -58,10 +58,10 @@ impl BitStream { bitStream: *mut BitStream, numberOfBits: ::std::os::raw::c_uint, ) { - unsafe { BitStream_Write1(self, bitStream, numberOfBits) } + BitStream_Write1(self, bitStream, numberOfBits) } #[inline] pub unsafe fn Write11(&mut self) { - unsafe { BitStream_Write11(self) } + BitStream_Write11(self) } } diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs index 5ad4b23f7b..c834752e3c 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)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -29,8 +29,8 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym)?; - let baz = unsafe { __library.get(b"baz\0") }.map(|sym| *sym)?; + let foo = __library.get(b"foo\0").map(|sym| *sym)?; + let baz = __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 { - unsafe { (self.foo)(x, y) } + (self.foo)(x, y) } pub unsafe fn baz(&self) -> ::std::os::raw::c_int { - unsafe { (self.baz)() } + (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 723f44ad09..e46ffd49e0 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)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -32,9 +32,9 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - 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)?; + 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)?; 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 { - unsafe { (self.foo)(x, y) } + (self.foo)(x, y) } pub unsafe fn bar( &self, x: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - unsafe { (self.bar)(x) } + (self.bar)(x) } pub unsafe fn baz(&self) -> ::std::os::raw::c_int { - unsafe { (self.baz)() } + (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 5864ba0a8d..cae5bd6937 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)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -41,9 +41,9 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - 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); + 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); Ok(TestLib { __library, foo, @@ -56,19 +56,15 @@ impl TestLib { x: ::std::os::raw::c_int, y: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - unsafe { - (self.foo.as_ref().expect("Expected function, got error."))(x, y) - } + (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 { - unsafe { - (self.bar.as_ref().expect("Expected function, got error."))(x) - } + (self.bar.as_ref().expect("Expected function, got error."))(x) } pub unsafe fn baz(&self) -> ::std::os::raw::c_int { - unsafe { (self.baz.as_ref().expect("Expected function, got error."))() } + (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 6c9ea27496..06e67ed791 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)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -29,8 +29,8 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym); - let foo1 = unsafe { __library.get(b"foo1\0") }.map(|sym| *sym); + let foo = __library.get(b"foo\0").map(|sym| *sym); + let foo1 = __library.get(b"foo1\0").map(|sym| *sym); Ok(TestLib { __library, foo, @@ -41,13 +41,9 @@ impl TestLib { &self, x: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - unsafe { - (self.foo.as_ref().expect("Expected function, got error."))(x) - } + (self.foo.as_ref().expect("Expected function, got error."))(x) } pub unsafe fn foo1(&self, x: f32) -> f32 { - unsafe { - (self.foo1.as_ref().expect("Expected function, got error."))(x) - } + (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 c9b2471419..97bb67abdc 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)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -43,9 +43,9 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - 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); + 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); Ok(TestLib { __library, foo, @@ -57,16 +57,12 @@ impl TestLib { &self, x: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - unsafe { - (self.foo.as_ref().expect("Expected function, got error."))(x) - } + (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 { - unsafe { - (self.baz.as_ref().expect("Expected function, got error."))(x) - } + (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 30f2be1d1e..af482ad938 100644 --- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs +++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs @@ -46,19 +46,17 @@ extern "C" { impl X { #[inline] pub unsafe fn some_function(&mut self) { - unsafe { X_some_function(self) } + X_some_function(self) } #[inline] pub unsafe fn some_other_function(&mut self) { - unsafe { X_some_other_function(self) } + X_some_other_function(self) } #[inline] pub unsafe fn new(x: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - X_X(__bindgen_tmp.as_mut_ptr(), x); - __bindgen_tmp.assume_init() - } + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + X_X(__bindgen_tmp.as_mut_ptr(), x); + __bindgen_tmp.assume_init() } } extern crate libloading; @@ -83,7 +81,7 @@ impl TestLib { P: AsRef<::std::ffi::OsStr>, { let library = ::libloading::Library::new(path)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -92,8 +90,8 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym); - let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym); + let foo = __library.get(b"foo\0").map(|sym| *sym); + let bar = __library.get(b"bar\0").map(|sym| *sym); Ok(TestLib { __library, foo, @@ -104,16 +102,12 @@ impl TestLib { &self, x: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - unsafe { - (self.foo.as_ref().expect("Expected function, got error."))(x) - } + (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 { - unsafe { - (self.bar.as_ref().expect("Expected function, got error."))(x) - } + (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 d928751892..514cff7317 100644 --- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs +++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs @@ -46,19 +46,17 @@ extern "C" { impl A { #[inline] pub unsafe fn some_function(&mut self) { - unsafe { A_some_function(self) } + A_some_function(self) } #[inline] pub unsafe fn some_other_function(&mut self) { - unsafe { A_some_other_function(self) } + A_some_other_function(self) } #[inline] pub unsafe fn new(x: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - A_A(__bindgen_tmp.as_mut_ptr(), x); - __bindgen_tmp.assume_init() - } + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + A_A(__bindgen_tmp.as_mut_ptr(), x); + __bindgen_tmp.assume_init() } } extern crate libloading; @@ -78,7 +76,7 @@ impl TestLib { P: AsRef<::std::ffi::OsStr>, { let library = ::libloading::Library::new(path)?; - unsafe { Self::from_library(library) } + Self::from_library(library) } pub unsafe fn from_library( library: L, @@ -87,8 +85,8 @@ impl TestLib { L: Into<::libloading::Library>, { let __library = library.into(); - let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym); - let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym); + let foo = __library.get(b"foo\0").map(|sym| *sym); + let bar = __library.get(b"bar\0").map(|sym| *sym); Ok(TestLib { __library, foo, @@ -99,11 +97,9 @@ impl TestLib { &self, x: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - unsafe { - (self.foo.as_ref().expect("Expected function, got error."))(x) - } + (self.foo.as_ref().expect("Expected function, got error."))(x) } pub unsafe fn bar(&self) -> () { - unsafe { (self.bar.as_ref().expect("Expected function, got error."))() } + (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 59af8ef30c..89b8637954 100644 --- a/bindgen-tests/tests/expectations/tests/gen-constructors.rs +++ b/bindgen-tests/tests/expectations/tests/gen-constructors.rs @@ -30,10 +30,8 @@ extern "C" { impl Foo { #[inline] pub unsafe fn new(a: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - Foo_Foo(__bindgen_tmp.as_mut_ptr(), a); - __bindgen_tmp.assume_init() - } + 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 4109520987..1711f76d0c 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) { - unsafe { Foo_Foo_destructor(self) } + 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 9ac66b0f7b..3cb865a4d7 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 { - unsafe { Foo_bar() } + 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 d1ae7ebd2b..18061ea12a 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { diff --git a/bindgen-tests/tests/expectations/tests/issue-2019.rs b/bindgen-tests/tests/expectations/tests/issue-2019.rs index 89f1ac6268..294e9f0e83 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 { - unsafe { make() } + make() } } #[repr(C)] @@ -74,6 +74,6 @@ extern "C" { impl B { #[inline] pub unsafe fn make() -> B { - unsafe { make1() } + make1() } } diff --git a/bindgen-tests/tests/expectations/tests/issue-410.rs b/bindgen-tests/tests/expectations/tests/issue-410.rs index 739ddf29ce..ad7463c266 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) { - unsafe { Value_a(self, arg1) } + 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 0a6dd5e6b8..949db73b79 100644 --- a/bindgen-tests/tests/expectations/tests/issue-447.rs +++ b/bindgen-tests/tests/expectations/tests/issue-447.rs @@ -65,14 +65,12 @@ pub mod root { pub unsafe fn new( arg1: root::mozilla::detail::GuardObjectNotifier, ) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - JSAutoCompartment_JSAutoCompartment( - __bindgen_tmp.as_mut_ptr(), - arg1, - ); - __bindgen_tmp.assume_init() - } + 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 019982dbb9..61c7f7929e 100644 --- a/bindgen-tests/tests/expectations/tests/issue-493.rs +++ b/bindgen-tests/tests/expectations/tests/issue-493.rs @@ -14,11 +14,11 @@ impl __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 12a1e7a267..1a0131c327 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 03162c4c9f..b69aa16ef3 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 dc0b7f08d9..f886952822 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,15 +89,13 @@ extern "C" { impl Opaque { #[inline] pub unsafe fn eleven_out_of_ten(&mut self) -> SuchWow { - unsafe { Opaque_eleven_out_of_ten(self) } + Opaque_eleven_out_of_ten(self) } #[inline] pub unsafe fn new(pup: Pupper) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - Opaque_Opaque(__bindgen_tmp.as_mut_ptr(), pup); - __bindgen_tmp.assume_init() - } + 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 32af443f29..b439499355 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/layout_align.rs b/bindgen-tests/tests/expectations/tests/layout_align.rs index 718a8024a6..466e76862c 100644 --- a/bindgen-tests/tests/expectations/tests/layout_align.rs +++ b/bindgen-tests/tests/expectations/tests/layout_align.rs @@ -109,11 +109,11 @@ impl __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 de814146e1..d7fa0a634a 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 f0b312a037..075ef46ae4 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 3788d3d0a4..90f7ed09b2 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 85ca160107..53caa661c6 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: Sized + std::ops::Deref { where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, get) } + msg_send!(*self, get) } } #[repr(transparent)] @@ -59,6 +59,6 @@ pub trait IFooMultiGeneric: where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, objectForKey: key) } + 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 7d732bb09a..0d64a9ffc8 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { @@ -674,18 +674,18 @@ extern "C" { impl RealAbstractionWithTonsOfMethods { #[inline] pub unsafe fn bar(&self) { - unsafe { RealAbstractionWithTonsOfMethods_bar(self) } + RealAbstractionWithTonsOfMethods_bar(self) } #[inline] pub unsafe fn bar1(&mut self) { - unsafe { RealAbstractionWithTonsOfMethods_bar1(self) } + RealAbstractionWithTonsOfMethods_bar1(self) } #[inline] pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { - unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) } + RealAbstractionWithTonsOfMethods_bar2(self, foo) } #[inline] pub unsafe fn sta() { - unsafe { RealAbstractionWithTonsOfMethods_sta() } + 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 4364c69a74..e8c2e07798 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { @@ -44,11 +44,11 @@ impl __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { @@ -725,18 +725,18 @@ impl Clone for RealAbstractionWithTonsOfMethods { impl RealAbstractionWithTonsOfMethods { #[inline] pub unsafe fn bar(&self) { - unsafe { RealAbstractionWithTonsOfMethods_bar(self) } + RealAbstractionWithTonsOfMethods_bar(self) } #[inline] pub unsafe fn bar1(&mut self) { - unsafe { RealAbstractionWithTonsOfMethods_bar1(self) } + RealAbstractionWithTonsOfMethods_bar1(self) } #[inline] pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { - unsafe { RealAbstractionWithTonsOfMethods_bar2(self, foo) } + RealAbstractionWithTonsOfMethods_bar2(self, foo) } #[inline] pub unsafe fn sta() { - unsafe { RealAbstractionWithTonsOfMethods_sta() } + 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 17154e4d1a..2af22cc4c9 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 441c3f69b2..1de963bf0f 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 4161c6dbfc..ab402cfb7c 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { 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 df940912b3..f6a32704f1 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { @@ -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 90d9d9931b..3c615035ce 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: Sized + std::ops::Deref { where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, get) } + msg_send!(*self, get) } } #[repr(transparent)] @@ -59,6 +59,6 @@ pub trait IFooMultiGeneric: where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, objectForKey: key) } + 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 71a2d6d6aa..3066fac40a 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { diff --git a/bindgen-tests/tests/expectations/tests/method-mangling.rs b/bindgen-tests/tests/expectations/tests/method-mangling.rs index 5f8a847452..e4627ac8a7 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 { - unsafe { Foo_type(self) } + Foo_type(self) } } diff --git a/bindgen-tests/tests/expectations/tests/objc_allowlist.rs b/bindgen-tests/tests/expectations/tests/objc_allowlist.rs index 76971a5f38..370cab9332 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, protocolMethod) } + msg_send!(*self, protocolMethod) } unsafe fn protocolClassMethod() where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(SomeProtocol), protocolClassMethod) } + msg_send!(class!(SomeProtocol), protocolClassMethod) } } #[repr(transparent)] @@ -45,13 +45,13 @@ pub trait IAllowlistMe: Sized + std::ops::Deref { where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, method) } + msg_send!(*self, method) } unsafe fn classMethod() where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(AllowlistMe), classMethod) } + 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 f16eb0f929..7d5d19b083 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, ambiguouslyBlockedMethod) } + msg_send!(*self, ambiguouslyBlockedMethod) } unsafe fn instanceMethod(&self) where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, instanceMethod) } + 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 f05c2bbd9b..9d60233bed 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, method) } + msg_send!(*self, method) } } impl Foo_BarCategory for Foo {} @@ -39,6 +39,6 @@ pub trait Foo_BarCategory: Sized + std::ops::Deref { where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, categoryMethod) } + 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 0fe8e254c3..b322bddcb6 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, method) } + 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 796698d271..29e70256ff 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), method) } + msg_send!(class!(Foo), method) } unsafe fn methodWithInt_(foo: ::std::os::raw::c_int) where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), methodWithInt: foo) } + msg_send!(class!(Foo), methodWithInt: foo) } unsafe fn methodWithFoo_(foo: Foo) where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), methodWithFoo: foo) } + msg_send!(class!(Foo), methodWithFoo: foo) } unsafe fn methodReturningInt() -> ::std::os::raw::c_int where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), methodReturningInt) } + msg_send!(class!(Foo), methodReturningInt) } unsafe fn methodReturningFoo() -> Foo where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), methodReturningFoo) } + msg_send!(class!(Foo), methodReturningFoo) } unsafe fn methodWithArg1_andArg2_andArg3_( intvalue: ::std::os::raw::c_int, @@ -63,8 +63,6 @@ pub trait IFoo: Sized + std::ops::Deref { ) where ::Target: objc::Message + Sized, { - unsafe { - msg_send ! (class ! (Foo) , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue) - } + 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 8962413e24..593fd27738 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, method) } + msg_send!(*self, method) } unsafe fn methodWithInt_(&self, foo: ::std::os::raw::c_int) where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, methodWithInt: foo) } + msg_send!(*self, methodWithInt: foo) } unsafe fn methodWithFoo_(&self, foo: Foo) where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, methodWithFoo: foo) } + msg_send!(*self, methodWithFoo: foo) } unsafe fn methodReturningInt(&self) -> ::std::os::raw::c_int where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, methodReturningInt) } + msg_send!(*self, methodReturningInt) } unsafe fn methodReturningFoo(&self) -> Foo where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, methodReturningFoo) } + msg_send!(*self, methodReturningFoo) } unsafe fn methodWithArg1_andArg2_andArg3_( &self, @@ -64,9 +64,7 @@ pub trait IFoo: Sized + std::ops::Deref { ) where ::Target: objc::Message + Sized, { - unsafe { - msg_send ! (* self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue) - } + msg_send ! (* self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue) } unsafe fn methodWithAndWithoutKeywords_arg2Name__arg4Name_( &self, @@ -78,9 +76,7 @@ pub trait IFoo: Sized + std::ops::Deref { where ::Target: objc::Message + Sized, { - unsafe { - msg_send ! (* self , methodWithAndWithoutKeywords : arg1 arg2Name : arg2 arg3 : arg3 arg4Name : arg4) - } + 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 bd2df7d0d6..ac77cc19e3 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, foo) } + msg_send!(*self, foo) } unsafe fn class_foo() where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), foo) } + 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 d49f17c1a6..1ec8494d25 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, methodUsingBar: my_bar) } + msg_send!(*self, methodUsingBar: my_bar) } unsafe fn methodReturningBar() -> Bar where ::Target: objc::Message + Sized, { - unsafe { msg_send!(class!(Foo), methodReturningBar) } + 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 90a3dc8dea..9f3fabd272 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 ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, func) } + msg_send!(*self, func) } unsafe fn setFunc_( &self, @@ -52,6 +52,6 @@ pub trait IFoo: Sized + std::ops::Deref { ) where ::Target: objc::Message + Sized, { - unsafe { msg_send!(*self, setFunc: func) } + 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 4738b301e7..9f7dd20ad9 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) { - unsafe { Struct_Function(self, arg1) } + 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 1d095b8d0b..979dd4b564 100644 --- a/bindgen-tests/tests/expectations/tests/public-dtor.rs +++ b/bindgen-tests/tests/expectations/tests/public-dtor.rs @@ -1,53 +1,53 @@ -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] - -#[repr(C)] -#[derive(Debug, Default)] -pub struct cv_Foo { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_cv_Foo() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(cv_Foo)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(cv_Foo)) - ); -} -extern "C" { - #[link_name = "\u{1}_ZN2cv3FooD1Ev"] - pub fn cv_Foo_Foo_destructor(this: *mut cv_Foo); -} -impl cv_Foo { - #[inline] - pub unsafe fn destruct(&mut self) { - unsafe { cv_Foo_Foo_destructor(self) } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct cv_Bar { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_cv_Bar() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(cv_Bar)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(cv_Bar)) - ); -} +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +#[repr(C)] +#[derive(Debug, Default)] +pub struct cv_Foo { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_cv_Foo() { + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(cv_Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(cv_Foo)) + ); +} +extern "C" { + #[link_name = "\u{1}_ZN2cv3FooD1Ev"] + pub fn cv_Foo_Foo_destructor(this: *mut cv_Foo); +} +impl cv_Foo { + #[inline] + pub unsafe fn destruct(&mut self) { + cv_Foo_Foo_destructor(self) + } +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct cv_Bar { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_cv_Bar() { + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(cv_Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(cv_Bar)) + ); +} 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 fd4d561b79..8db33d113e 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 52c6904c26..55432d47fc 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 a777adf360..af795b6423 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/transform-op.rs b/bindgen-tests/tests/expectations/tests/transform-op.rs index eec37a3dae..84a9460362 100644 --- a/bindgen-tests/tests/expectations/tests/transform-op.rs +++ b/bindgen-tests/tests/expectations/tests/transform-op.rs @@ -14,11 +14,11 @@ impl __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs b/bindgen-tests/tests/expectations/tests/typeref_1_0.rs index 3376bf0438..8e4143c082 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 63e3978199..a057cc348a 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 { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 f15ce0f020..2227746849 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/union_dtor.rs b/bindgen-tests/tests/expectations/tests/union_dtor.rs index cb363de6b5..085e5ca30a 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) { - unsafe { UnionWithDtor_UnionWithDtor_destructor(self) } + 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 519bd8692f..67455aa8b8 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { @@ -98,6 +98,6 @@ extern "C" { impl UnionWithDtor { #[inline] pub unsafe fn destruct(&mut self) { - unsafe { UnionWithDtor_UnionWithDtor_destructor(self) } + 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 621a961f4f..b5f94bcd05 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 543f154d05..487579f7e5 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 316f8453e5..8b11e75796 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 c06f6489b9..6ce6ed2282 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 6c856634da..f3e4b84003 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 d4c6fec977..1562a8c971 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 96f03680aa..197a6bbfbc 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 869720d442..63b43baa82 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 4b1ab55336..a1e452fe03 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 227afaffcc..3c500b2106 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::std::mem::transmute(self) } + ::std::mem::transmute(self) } } impl ::std::default::Default for __BindgenUnionField { 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 0310211d88..8c6d0fd272 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 __BindgenUnionField { } #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { ::core::mem::transmute(self) } + ::core::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { ::core::mem::transmute(self) } + ::core::mem::transmute(self) } } impl ::core::default::Default for __BindgenUnionField { diff --git a/bindgen-tests/tests/expectations/tests/var-tracing.rs b/bindgen-tests/tests/expectations/tests/var-tracing.rs index 22e7e6ed69..37fdd95105 100644 --- a/bindgen-tests/tests/expectations/tests/var-tracing.rs +++ b/bindgen-tests/tests/expectations/tests/var-tracing.rs @@ -43,11 +43,9 @@ extern "C" { impl Bar { #[inline] pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - Bar_Bar(__bindgen_tmp.as_mut_ptr(), baz); - __bindgen_tmp.assume_init() - } + 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 909d04ded4..6d15c51f9d 100644 --- a/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs +++ b/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs @@ -33,10 +33,8 @@ extern "C" { impl Foo { #[inline] pub unsafe fn new(var: ::std::os::raw::c_int) -> Self { - unsafe { - let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); - Foo_Foo(__bindgen_tmp.as_mut_ptr(), var); - __bindgen_tmp.assume_init() - } + 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 f144edd4d0..92bb13cc61 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) { - unsafe { Foo_test(self) } + Foo_test(self) } #[inline] pub unsafe fn test2( &mut self, var: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - unsafe { Foo_test2(self, var) } + 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 e99abb8721..d7d0f6613d 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { diff --git a/bindgen-tests/tests/expectations/tests/zero-sized-array.rs b/bindgen-tests/tests/expectations/tests/zero-sized-array.rs index 27c48f0e25..4ba52498c4 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 __IncompleteArrayField { } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { ::std::slice::from_raw_parts(self.as_ptr(), len) } + ::std::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::std::fmt::Debug for __IncompleteArrayField { diff --git a/bindgen/codegen/dyngen.rs b/bindgen/codegen/dyngen.rs index f310f14e08..d02c51e420 100644 --- a/bindgen/codegen/dyngen.rs +++ b/bindgen/codegen/dyngen.rs @@ -92,9 +92,7 @@ impl DynamicItems { ) -> Result where P: AsRef<::std::ffi::OsStr> { let library = ::libloading::Library::new(path)?; - unsafe { - Self::from_library(library) - } + Self::from_library(library) } pub unsafe fn from_library( @@ -159,9 +157,7 @@ impl DynamicItems { self.struct_implementation.push(quote! { #(#attributes)* pub unsafe fn #ident ( &self, #( #args ),* ) -> #ret_ty { - unsafe { - #call_body - } + #call_body } }); } @@ -170,11 +166,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 = unsafe { __library.get(#ident_str) }.map(|sym| *sym)?; + let #ident = __library.get(#ident_str).map(|sym| *sym)?; } } else { quote! { - let #ident = unsafe { __library.get(#ident_str) }.map(|sym| *sym); + let #ident = __library.get(#ident_str).map(|sym| *sym); } }); diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index c7ac59db42..9f83913efa 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -2611,9 +2611,7 @@ impl MethodCodegen for Method { methods.push(quote! { #(#attrs)* pub unsafe fn #name ( #( #args ),* ) #ret { - unsafe { - #block - } + #block } }); } @@ -4271,9 +4269,7 @@ fn objc_method_codegen( methods.push(quote! { unsafe fn #method_name #sig where ::Target: objc::Message + Sized { - unsafe { - #body - } + #body } }); } @@ -4648,16 +4644,12 @@ pub mod utils { #[inline] pub unsafe fn as_ref(&self) -> &T { - unsafe { - ::#prefix::mem::transmute(self) - } + ::#prefix::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - unsafe { - ::#prefix::mem::transmute(self) - } + ::#prefix::mem::transmute(self) } } }; @@ -4771,16 +4763,12 @@ pub mod utils { #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - unsafe { - ::#prefix::slice::from_raw_parts(self.as_ptr(), len) - } + ::#prefix::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - unsafe { - ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len) - } + ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } };