diff --git a/bindgen-tests/tests/expectations/tests/16-byte-alignment.rs b/bindgen-tests/tests/expectations/tests/16-byte-alignment.rs
index c55d0b075b..af5d373a9e 100644
--- a/bindgen-tests/tests/expectations/tests/16-byte-alignment.rs
+++ b/bindgen-tests/tests/expectations/tests/16-byte-alignment.rs
@@ -1,19 +1,19 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub struct rte_ipv4_tuple {
pub src_addr: u32,
pub dst_addr: u32,
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1,
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union rte_ipv4_tuple__bindgen_ty_1 {
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1,
pub sctp_tag: u32,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 {
pub dport: u16,
pub sport: u16,
@@ -77,20 +77,20 @@ impl Default for rte_ipv4_tuple {
}
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub struct rte_ipv6_tuple {
pub src_addr: [u8; 16usize],
pub dst_addr: [u8; 16usize],
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1,
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union rte_ipv6_tuple__bindgen_ty_1 {
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1,
pub sctp_tag: u32,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 {
pub dport: u16,
pub sport: u16,
@@ -155,7 +155,7 @@ impl Default for rte_ipv6_tuple {
}
#[repr(C)]
#[repr(align(16))]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union rte_thash_tuple {
pub v4: rte_ipv4_tuple,
pub v6: rte_ipv6_tuple,
diff --git a/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs b/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs
index ed893c21df..203bbe83d0 100644
--- a/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs
+++ b/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct std_allocator_traits {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/accessors.rs b/bindgen-tests/tests/expectations/tests/accessors.rs
index 586edf2d79..f079a36abf 100644
--- a/bindgen-tests/tests/expectations/tests/accessors.rs
+++ b/bindgen-tests/tests/expectations/tests/accessors.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct SomeAccessors {
pub mNoAccessor: ::std::os::raw::c_int,
///
@@ -51,7 +51,7 @@ impl SomeAccessors {
}
///
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct AllAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
pub mAlsoBothAccessors: ::std::os::raw::c_int,
@@ -87,7 +87,7 @@ impl AllAccessors {
}
///
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct AllUnsafeAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
pub mAlsoBothAccessors: ::std::os::raw::c_int,
@@ -125,7 +125,7 @@ impl AllUnsafeAccessors {
}
///
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct ContradictAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
///
@@ -180,7 +180,7 @@ impl ContradictAccessors {
}
///
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Replaced {
pub mAccessor: ::std::os::raw::c_int,
}
@@ -204,7 +204,7 @@ impl Replaced {
}
///
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Wrapper {
pub mReplaced: Replaced,
}
diff --git a/bindgen-tests/tests/expectations/tests/alias_comments.rs b/bindgen-tests/tests/expectations/tests/alias_comments.rs
index 31ff72b2c6..5d23e8cee0 100644
--- a/bindgen-tests/tests/expectations/tests/alias_comments.rs
+++ b/bindgen-tests/tests/expectations/tests/alias_comments.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
/// This is Struct
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Struct {
/// This is field
pub field: ::std::os::raw::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/allowlist-file.rs b/bindgen-tests/tests/expectations/tests/allowlist-file.rs
index b1fb170de0..4160f7febf 100644
--- a/bindgen-tests/tests/expectations/tests/allowlist-file.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlist-file.rs
@@ -8,7 +8,7 @@ unsafe extern "C" {
pub static mut someVar: ::std::os::raw::c_int;
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct someClass {
pub _address: u8,
}
@@ -35,7 +35,7 @@ unsafe extern "C" {
pub fn foo_NamespacedFunction();
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct StructWithAllowlistedDefinition {
pub other: *mut StructWithAllowlistedFwdDecl,
}
@@ -61,7 +61,7 @@ impl Default for StructWithAllowlistedDefinition {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct StructWithAllowlistedFwdDecl {
pub b: ::std::os::raw::c_int,
}
@@ -78,7 +78,7 @@ const _: () = {
][::std::mem::offset_of!(StructWithAllowlistedFwdDecl, b) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct AllowlistMe {
pub foo: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/allowlist-namespaces-basic.rs b/bindgen-tests/tests/expectations/tests/allowlist-namespaces-basic.rs
index 151d03f4a4..f904fcd53d 100644
--- a/bindgen-tests/tests/expectations/tests/allowlist-namespaces-basic.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlist-namespaces-basic.rs
@@ -10,7 +10,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::super::root;
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Helper {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/allowlist-namespaces.rs b/bindgen-tests/tests/expectations/tests/allowlist-namespaces.rs
index 563c97ca1d..9bfa850de0 100644
--- a/bindgen-tests/tests/expectations/tests/allowlist-namespaces.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlist-namespaces.rs
@@ -10,7 +10,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::super::root;
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Helper {
pub _address: u8,
}
@@ -21,7 +21,7 @@ pub mod root {
};
}
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Test {
pub helper: root::outer::inner::Helper,
}
diff --git a/bindgen-tests/tests/expectations/tests/allowlist_basic.rs b/bindgen-tests/tests/expectations/tests/allowlist_basic.rs
index a1c6919739..77842fe620 100644
--- a/bindgen-tests/tests/expectations/tests/allowlist_basic.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlist_basic.rs
@@ -1,13 +1,13 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct AllowlistMe {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub foo: ::std::os::raw::c_int,
pub bar: AllowlistMe_Inner,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct AllowlistMe_Inner {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub bar: T,
diff --git a/bindgen-tests/tests/expectations/tests/allowlist_item.rs b/bindgen-tests/tests/expectations/tests/allowlist_item.rs
index 93eab7e147..304d942759 100644
--- a/bindgen-tests/tests/expectations/tests/allowlist_item.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlist_item.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub const FooDefault: u32 = 0;
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub field: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-hash.rs b/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-hash.rs
index 6c1d13a837..3f066b9c89 100644
--- a/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-hash.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-hash.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct NoHash {
pub _address: u8,
}
@@ -10,7 +10,7 @@ const _: () = {
["Alignment of NoHash"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct AllowlistMe {
pub a: NoHash,
}
diff --git a/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-partialeq.rs b/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-partialeq.rs
index b969727dbb..f39783d58b 100644
--- a/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-partialeq.rs
+++ b/bindgen-tests/tests/expectations/tests/allowlisted-item-references-no-partialeq.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct NoPartialEq {
pub _address: u8,
}
@@ -10,7 +10,7 @@ const _: () = {
["Alignment of NoPartialEq"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct AllowlistMe {
pub a: NoPartialEq,
}
diff --git a/bindgen-tests/tests/expectations/tests/annotation_hide.rs b/bindgen-tests/tests/expectations/tests/annotation_hide.rs
index e79c88214d..2c35d93360 100644
--- a/bindgen-tests/tests/expectations/tests/annotation_hide.rs
+++ b/bindgen-tests/tests/expectations/tests/annotation_hide.rs
@@ -2,7 +2,7 @@
///
#[repr(C)]
#[repr(align(4))]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct D {
pub _bindgen_opaque_blob: u32,
}
@@ -12,7 +12,7 @@ const _: () = {
["Alignment of D"][::std::mem::align_of::() - 4usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct NotAnnotated {
pub f: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/anon-fields-prefix.rs b/bindgen-tests/tests/expectations/tests/anon-fields-prefix.rs
index 2b96804c9b..f2100fec9a 100644
--- a/bindgen-tests/tests/expectations/tests/anon-fields-prefix.rs
+++ b/bindgen-tests/tests/expectations/tests/anon-fields-prefix.rs
@@ -1,13 +1,13 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union color {
pub u1: color__bindgen_ty_1,
pub u2: color__bindgen_ty_2,
pub v3: [::std::os::raw::c_uchar; 3usize],
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct color__bindgen_ty_1 {
pub r: ::std::os::raw::c_uchar,
pub g: ::std::os::raw::c_uchar,
@@ -32,7 +32,7 @@ const _: () = {
][::std::mem::offset_of!(color__bindgen_ty_1, b) - 2usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct color__bindgen_ty_2 {
pub y: ::std::os::raw::c_uchar,
pub u: ::std::os::raw::c_uchar,
diff --git a/bindgen-tests/tests/expectations/tests/anon_enum.rs b/bindgen-tests/tests/expectations/tests/anon_enum.rs
index c3790a2a24..2a9d16b16b 100644
--- a/bindgen-tests/tests/expectations/tests/anon_enum.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_enum.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, PartialEq)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Test {
pub foo: ::std::os::raw::c_int,
pub bar: f32,
diff --git a/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs b/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs
index cfd4d03200..c5db9d757e 100644
--- a/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct DataType {
pub _address: u8,
}
@@ -19,7 +19,7 @@ pub enum DataType__bindgen_ty_1 {
generic_type = 0,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct Foo {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/anon_struct_in_union.rs b/bindgen-tests/tests/expectations/tests/anon_struct_in_union.rs
index dceca1adf3..81925eecd9 100644
--- a/bindgen-tests/tests/expectations/tests/anon_struct_in_union.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_struct_in_union.rs
@@ -1,16 +1,16 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub struct s {
pub u: s__bindgen_ty_1,
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union s__bindgen_ty_1 {
pub field: s__bindgen_ty_1_inner,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct s__bindgen_ty_1_inner {
pub b: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/anonymous-template-types.rs b/bindgen-tests/tests/expectations/tests/anonymous-template-types.rs
index f6c894d8b5..8403ef43d8 100644
--- a/bindgen-tests/tests/expectations/tests/anonymous-template-types.rs
+++ b/bindgen-tests/tests/expectations/tests/anonymous-template-types.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Foo {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub t_member: T,
@@ -15,12 +15,12 @@ impl Default for Foo {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct Bar {
pub member: ::std::os::raw::c_char,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Quux {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub v_member: V,
@@ -35,7 +35,7 @@ impl Default for Quux {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct Lobo {
pub also_member: ::std::os::raw::c_char,
}
diff --git a/bindgen-tests/tests/expectations/tests/array-of-zero-sized-types.rs b/bindgen-tests/tests/expectations/tests/array-of-zero-sized-types.rs
index 4630abd275..c67d8f88ac 100644
--- a/bindgen-tests/tests/expectations/tests/array-of-zero-sized-types.rs
+++ b/bindgen-tests/tests/expectations/tests/array-of-zero-sized-types.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
/// This should get an `_address` byte.
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Empty {
pub _address: u8,
}
@@ -13,7 +13,7 @@ const _: () = {
/** This should not get an `_address` byte, since each `Empty` gets one, meaning
that this object is addressable.*/
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct HasArrayOfEmpty {
pub empties: [Empty; 10usize],
}
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 ec152e1543..90c70961b1 100644
--- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs
+++ b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
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 f0fb434bcb..e10518364e 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
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/auto.rs b/bindgen-tests/tests/expectations/tests/auto.rs
index ba93e7a20b..d561e1869d 100644
--- a/bindgen-tests/tests/expectations/tests/auto.rs
+++ b/bindgen-tests/tests/expectations/tests/auto.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
@@ -11,7 +11,7 @@ const _: () = {
["Alignment of Foo"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Bar {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs b/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs
index 9ad8429e3c..7ddcb97c1d 100644
--- a/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs
+++ b/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct std_char_traits {
pub _address: u8,
}
@@ -14,7 +14,7 @@ impl Default for std_char_traits {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __gnu_cxx_char_traits {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/base-to-derived.rs b/bindgen-tests/tests/expectations/tests/base-to-derived.rs
index 22ef4fdb08..a81970ac8e 100644
--- a/bindgen-tests/tests/expectations/tests/base-to-derived.rs
+++ b/bindgen-tests/tests/expectations/tests/base-to-derived.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct false_type {
pub _address: u8,
}
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 2c8d2e5713..aff8ce29ac 100644
--- a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
+++ b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
@@ -7,7 +7,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
- #[derive(Copy, Clone)]
+ #[derive(Clone, Copy)]
pub union Bar {
pub foo: ::std::os::raw::c_int,
pub bar: ::std::os::raw::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield-32bit-overflow.rs b/bindgen-tests/tests/expectations/tests/bitfield-32bit-overflow.rs
index 783f0ef7a9..3d204a9718 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-32bit-overflow.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-32bit-overflow.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct MuchBitfield {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 5usize]>,
}
@@ -1370,7 +1376,7 @@ impl MuchBitfield {
m31: ::std::os::raw::c_char,
m32: ::std::os::raw::c_char,
) -> __BindgenBitfieldUnit<[u8; 5usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 5usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 5usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield-enum-basic.rs b/bindgen-tests/tests/expectations/tests/bitfield-enum-basic.rs
index aecb9dc639..312470697a 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-enum-basic.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-enum-basic.rs
@@ -101,7 +101,7 @@ impl ::std::ops::BitAndAssign for _bindgen_ty_1 {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct _bindgen_ty_1(pub ::std::os::raw::c_uint);
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Dummy {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/bitfield-large.rs b/bindgen-tests/tests/expectations/tests/bitfield-large.rs
index 5d614ab936..8d7e374dd7 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-large.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-large.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,13 +145,15 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
#[repr(align(16))]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct HasBigBitfield {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>,
}
@@ -195,7 +201,7 @@ impl HasBigBitfield {
}
#[inline]
pub fn new_bitfield_1(x: i128) -> __BindgenBitfieldUnit<[u8; 16usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 16usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -210,7 +216,7 @@ impl HasBigBitfield {
}
#[repr(C)]
#[repr(align(16))]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct HasTwoBigBitfields {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize]>,
}
@@ -298,7 +304,7 @@ impl HasTwoBigBitfields {
}
#[inline]
pub fn new_bitfield_1(x: i128, y: i128) -> __BindgenBitfieldUnit<[u8; 16usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 16usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield-linux-32.rs b/bindgen-tests/tests/expectations/tests/bitfield-linux-32.rs
index 3e676c53b5..aca9adb986 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-linux-32.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-linux-32.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Test {
pub foo: u64,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>,
@@ -226,7 +232,7 @@ impl Test {
}
#[inline]
pub fn new_bitfield_1(x: u64, y: u64) -> __BindgenBitfieldUnit<[u8; 8usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 8usize]);
__bindgen_bitfield_unit
.set(
0usize,
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 09ca005589..0298a3aa79 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
}
@@ -212,7 +218,7 @@ impl Foo {
pub fn new_bitfield_1(
type__bindgen_bitfield: ::std::os::raw::c_char,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield-template.rs b/bindgen-tests/tests/expectations/tests/bitfield-template.rs
index eb454e0db4..c2c265f35c 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield-template.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield-template.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct foo {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub member: T,
@@ -199,7 +205,7 @@ impl foo {
}
#[inline]
pub fn new_bitfield_1(b: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_align.rs b/bindgen-tests/tests/expectations/tests/bitfield_align.rs
index 0c70917fc5..115969f87a 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield_align.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield_align.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct A {
pub _bindgen_align: [u32; 0],
pub x: ::std::os::raw::c_uchar,
@@ -534,7 +540,7 @@ impl A {
b9: ::std::os::raw::c_uint,
b10: ::std::os::raw::c_uint,
) -> __BindgenBitfieldUnit<[u8; 2usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 2usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -629,7 +635,7 @@ impl A {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct B {
pub _bindgen_align: [u32; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
@@ -717,7 +723,7 @@ impl B {
foo: ::std::os::raw::c_uint,
bar: ::std::os::raw::c_uchar,
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 4usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -740,7 +746,7 @@ impl B {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct C {
pub x: ::std::os::raw::c_uchar,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
@@ -831,7 +837,7 @@ impl C {
b1: ::std::os::raw::c_uint,
b2: ::std::os::raw::c_uint,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -854,7 +860,7 @@ impl C {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Date1 {
pub _bindgen_align: [u16; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize]>,
@@ -1017,7 +1023,7 @@ impl Date1 {
nMonth: ::std::os::raw::c_ushort,
nYear: ::std::os::raw::c_ushort,
) -> __BindgenBitfieldUnit<[u8; 3usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 3usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 3usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -1058,7 +1064,7 @@ impl Date1 {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Date2 {
pub _bindgen_align: [u16; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
@@ -1257,7 +1263,7 @@ impl Date2 {
nYear: ::std::os::raw::c_ushort,
byte: ::std::os::raw::c_uchar,
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 4usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -1307,7 +1313,7 @@ impl Date2 {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Date3 {
pub _bindgen_align: [u16; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize]>,
@@ -1471,7 +1477,7 @@ impl Date3 {
nMonth: ::std::os::raw::c_ushort,
nYear: ::std::os::raw::c_ushort,
) -> __BindgenBitfieldUnit<[u8; 3usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 3usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 3usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_align_2.rs b/bindgen-tests/tests/expectations/tests/bitfield_align_2.rs
index b71bba18ad..7e2e4e7887 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield_align_2.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield_align_2.rs
@@ -1,16 +1,18 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#![cfg(not(target_os = "windows"))]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -33,12 +35,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -60,12 +62,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -90,6 +92,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -128,6 +131,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -142,7 +146,9 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
@@ -155,7 +161,7 @@ pub enum MyEnum {
FOUR = 3,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct TaggedPtr {
pub _bindgen_align: [u64; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>,
@@ -252,7 +258,7 @@ impl TaggedPtr {
tag: MyEnum,
ptr: ::std::os::raw::c_long,
) -> __BindgenBitfieldUnit<[u8; 8usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 8usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_comma_separated_derives.rs b/bindgen-tests/tests/expectations/tests/bitfield_comma_separated_derives.rs
new file mode 100644
index 0000000000..178a07e03f
--- /dev/null
+++ b/bindgen-tests/tests/expectations/tests/bitfield_comma_separated_derives.rs
@@ -0,0 +1,433 @@
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
+pub struct __BindgenBitfieldUnit {
+ storage: Storage,
+}
+#[allow(unused_qualifications)]
+impl __BindgenBitfieldUnit {
+ #[inline]
+ pub const fn new(storage: Storage) -> Self {
+ Self { storage }
+ }
+}
+#[allow(unused_qualifications)]
+impl __BindgenBitfieldUnit
+where
+ Storage: AsRef<[u8]> + AsMut<[u8]>,
+{
+ #[inline]
+ fn extract_bit(byte: u8, index: usize) -> bool {
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
+ byte & mask == mask
+ }
+ #[inline]
+ pub fn get_bit(&self, index: usize) -> bool {
+ debug_assert!(index / 8 < self.storage.as_ref().len());
+ let byte_index = index / 8;
+ let byte = self.storage.as_ref()[byte_index];
+ Self::extract_bit(byte, index)
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
+ debug_assert!(index / 8 < core::mem::size_of::());
+ let byte_index = index / 8;
+ let byte = unsafe {
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
+ };
+ Self::extract_bit(byte, index)
+ }
+ #[inline]
+ fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
+ if val { byte | mask } else { byte & !mask }
+ }
+ #[inline]
+ pub fn set_bit(&mut self, index: usize, val: bool) {
+ debug_assert!(index / 8 < self.storage.as_ref().len());
+ let byte_index = index / 8;
+ let byte = &mut self.storage.as_mut()[byte_index];
+ *byte = Self::change_bit(*byte, index, val);
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
+ debug_assert!(index / 8 < core::mem::size_of::());
+ let byte_index = index / 8;
+ let byte = unsafe {
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
+ };
+ unsafe { *byte = Self::change_bit(*byte, index, val) };
+ }
+ #[inline]
+ pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),
+ );
+ let mut val = 0;
+ for i in 0..(bit_width as usize) {
+ if self.get_bit(i + bit_offset) {
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
+ }
+ }
+ val
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < core::mem::size_of::());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::(),
+ );
+ let mut val = 0;
+ for i in 0..(bit_width as usize) {
+ if unsafe { Self::raw_get_bit(this, i + bit_offset) } {
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
+ }
+ }
+ val
+ }
+ #[inline]
+ pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),
+ );
+ for i in 0..(bit_width as usize) {
+ let mask = 1 << i;
+ let val_bit_is_set = val & mask == mask;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
+ }
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < core::mem::size_of::());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::(),
+ );
+ for i in 0..(bit_width as usize) {
+ let mask = 1 << i;
+ let val_bit_is_set = val & mask == mask;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
+ }
+ }
+}
+///
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
+pub struct first_bitfield_struct {
+ pub _bindgen_align: [u32; 0],
+ pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+ pub __bindgen_padding_0: [u8; 3usize],
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of first_bitfield_struct",
+ ][::std::mem::size_of::() - 4usize];
+ [
+ "Alignment of first_bitfield_struct",
+ ][::std::mem::align_of::() - 4usize];
+};
+impl first_bitfield_struct {
+ #[inline]
+ pub fn a(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
+ }
+ #[inline]
+ pub fn set_a(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 1u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn a_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_a_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 0usize,
+ 1u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn b(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u32) }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(1usize, 2u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn b_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 2u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_b_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 1usize,
+ 2u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn c(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 3u8) as u32) }
+ }
+ #[inline]
+ pub fn set_c(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(3usize, 3u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn c_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 3usize, 3u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_c_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 3usize,
+ 3u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(
+ a: ::std::os::raw::c_uint,
+ b: ::std::os::raw::c_uint,
+ c: ::std::os::raw::c_uint,
+ ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
+ __bindgen_bitfield_unit
+ .set(
+ 0usize,
+ 1u8,
+ {
+ let a: u32 = unsafe { ::std::mem::transmute(a) };
+ a as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ .set(
+ 1usize,
+ 2u8,
+ {
+ let b: u32 = unsafe { ::std::mem::transmute(b) };
+ b as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ .set(
+ 3usize,
+ 3u8,
+ {
+ let c: u32 = unsafe { ::std::mem::transmute(c) };
+ c as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ }
+}
+///
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default)]
+pub struct second_bitfield_struct {
+ pub _bindgen_align: [u32; 0],
+ pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+ pub __bindgen_padding_0: [u8; 3usize],
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of second_bitfield_struct",
+ ][::std::mem::size_of::() - 4usize];
+ [
+ "Alignment of second_bitfield_struct",
+ ][::std::mem::align_of::() - 4usize];
+};
+impl second_bitfield_struct {
+ #[inline]
+ pub fn x(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u32) }
+ }
+ #[inline]
+ pub fn set_x(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 4u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn x_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 4u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_x_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 0usize,
+ 4u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn y(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u32) }
+ }
+ #[inline]
+ pub fn set_y(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(4usize, 4u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn y_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 4usize, 4u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_y_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 4usize,
+ 4u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(
+ x: ::std::os::raw::c_uint,
+ y: ::std::os::raw::c_uint,
+ ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
+ __bindgen_bitfield_unit
+ .set(
+ 0usize,
+ 4u8,
+ {
+ let x: u32 = unsafe { ::std::mem::transmute(x) };
+ x as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ .set(
+ 4usize,
+ 4u8,
+ {
+ let y: u32 = unsafe { ::std::mem::transmute(y) };
+ y as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ }
+}
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_large_overflow.rs b/bindgen-tests/tests/expectations/tests/bitfield_large_overflow.rs
index ac5d75735e..379c59daa8 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield_large_overflow.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield_large_overflow.rs
@@ -1,5 +1,5 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
+#[derive(Clone, Copy, Debug)]
#[repr(C, align(8))]
pub struct __BindgenOpaqueArray8(pub T);
impl Default for __BindgenOpaqueArray8<[T; N]> {
@@ -8,7 +8,7 @@ impl Default for __BindgenOpaqueArray8<[T; N]
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct _bindgen_ty_1 {
pub _bindgen_align: [u64; 0],
pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 80usize]>,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_method_mangling.rs b/bindgen-tests/tests/expectations/tests/bitfield_method_mangling.rs
index 35117c74b6..803cc76a73 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield_method_mangling.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield_method_mangling.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct mach_msg_type_descriptor_t {
pub _bindgen_align: [u32; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
@@ -238,7 +244,7 @@ impl mach_msg_type_descriptor_t {
pad3: ::std::os::raw::c_uint,
type_: ::std::os::raw::c_uint,
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 4usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_pack_offset.rs b/bindgen-tests/tests/expectations/tests/bitfield_pack_offset.rs
index d654e25b27..fea860f97f 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield_pack_offset.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield_pack_offset.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct A {
pub name: [::std::os::raw::c_uchar; 7usize],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 3usize]>,
@@ -360,7 +366,7 @@ impl A {
pestsBonus: ::std::os::raw::c_ushort,
size: ::std::os::raw::c_ushort,
) -> __BindgenBitfieldUnit<[u8; 3usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 3usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 3usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -483,7 +489,7 @@ impl A {
minYield: ::std::os::raw::c_uchar,
waterBonus: ::std::os::raw::c_uchar,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_pragma_packed.rs b/bindgen-tests/tests/expectations/tests/bitfield_pragma_packed.rs
index 6f9adcb5ab..809df5f965 100644
--- a/bindgen-tests/tests/expectations/tests/bitfield_pragma_packed.rs
+++ b/bindgen-tests/tests/expectations/tests/bitfield_pragma_packed.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,12 +145,14 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Struct {
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
}
@@ -341,7 +347,7 @@ impl Struct {
d: ::std::os::raw::c_ushort,
e: ::std::os::raw::c_uchar,
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 4usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -391,7 +397,7 @@ impl Struct {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Inner {
pub _bindgen_align: [u16; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>,
@@ -479,7 +485,7 @@ impl Inner {
a: ::std::os::raw::c_ushort,
b: ::std::os::raw::c_ushort,
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 4usize]);
__bindgen_bitfield_unit
.set(
0usize,
@@ -502,7 +508,7 @@ impl Inner {
}
}
#[repr(C, packed)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Outer {
pub inner: Inner,
}
diff --git a/bindgen-tests/tests/expectations/tests/bitfield_union_derives.rs b/bindgen-tests/tests/expectations/tests/bitfield_union_derives.rs
new file mode 100644
index 0000000000..81d3ae40d7
--- /dev/null
+++ b/bindgen-tests/tests/expectations/tests/bitfield_union_derives.rs
@@ -0,0 +1,503 @@
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
+pub struct __BindgenBitfieldUnit {
+ storage: Storage,
+}
+#[allow(unused_qualifications)]
+impl __BindgenBitfieldUnit {
+ #[inline]
+ pub const fn new(storage: Storage) -> Self {
+ Self { storage }
+ }
+}
+#[allow(unused_qualifications)]
+impl __BindgenBitfieldUnit
+where
+ Storage: AsRef<[u8]> + AsMut<[u8]>,
+{
+ #[inline]
+ fn extract_bit(byte: u8, index: usize) -> bool {
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
+ byte & mask == mask
+ }
+ #[inline]
+ pub fn get_bit(&self, index: usize) -> bool {
+ debug_assert!(index / 8 < self.storage.as_ref().len());
+ let byte_index = index / 8;
+ let byte = self.storage.as_ref()[byte_index];
+ Self::extract_bit(byte, index)
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
+ debug_assert!(index / 8 < core::mem::size_of::());
+ let byte_index = index / 8;
+ let byte = unsafe {
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
+ };
+ Self::extract_bit(byte, index)
+ }
+ #[inline]
+ fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
+ if val { byte | mask } else { byte & !mask }
+ }
+ #[inline]
+ pub fn set_bit(&mut self, index: usize, val: bool) {
+ debug_assert!(index / 8 < self.storage.as_ref().len());
+ let byte_index = index / 8;
+ let byte = &mut self.storage.as_mut()[byte_index];
+ *byte = Self::change_bit(*byte, index, val);
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
+ debug_assert!(index / 8 < core::mem::size_of::());
+ let byte_index = index / 8;
+ let byte = unsafe {
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
+ };
+ unsafe { *byte = Self::change_bit(*byte, index, val) };
+ }
+ #[inline]
+ pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),
+ );
+ let mut val = 0;
+ for i in 0..(bit_width as usize) {
+ if self.get_bit(i + bit_offset) {
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
+ }
+ }
+ val
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < core::mem::size_of::());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::(),
+ );
+ let mut val = 0;
+ for i in 0..(bit_width as usize) {
+ if unsafe { Self::raw_get_bit(this, i + bit_offset) } {
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
+ }
+ }
+ val
+ }
+ #[inline]
+ pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),
+ );
+ for i in 0..(bit_width as usize) {
+ let mask = 1 << i;
+ let val_bit_is_set = val & mask == mask;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
+ }
+ }
+ #[inline]
+ #[allow(dead_code)]
+ pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < core::mem::size_of::());
+ debug_assert!(
+ (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::(),
+ );
+ for i in 0..(bit_width as usize) {
+ let mask = 1 << i;
+ let val_bit_is_set = val & mask == mask;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
+ }
+ }
+}
+///
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+pub struct first_bitfield_struct {
+ pub _bindgen_align: [u32; 0],
+ pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+ pub __bindgen_padding_0: [u8; 3usize],
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of first_bitfield_struct",
+ ][::std::mem::size_of::() - 4usize];
+ [
+ "Alignment of first_bitfield_struct",
+ ][::std::mem::align_of::() - 4usize];
+};
+impl first_bitfield_struct {
+ #[inline]
+ pub fn a(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
+ }
+ #[inline]
+ pub fn set_a(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 1u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn a_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_a_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 0usize,
+ 1u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn b(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u32) }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(1usize, 2u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn b_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 2u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_b_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 1usize,
+ 2u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn c(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 3u8) as u32) }
+ }
+ #[inline]
+ pub fn set_c(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(3usize, 3u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn c_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 3usize, 3u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_c_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 3usize,
+ 3u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(
+ a: ::std::os::raw::c_uint,
+ b: ::std::os::raw::c_uint,
+ c: ::std::os::raw::c_uint,
+ ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
+ __bindgen_bitfield_unit
+ .set(
+ 0usize,
+ 1u8,
+ {
+ let a: u32 = unsafe { ::std::mem::transmute(a) };
+ a as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ .set(
+ 1usize,
+ 2u8,
+ {
+ let b: u32 = unsafe { ::std::mem::transmute(b) };
+ b as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ .set(
+ 3usize,
+ 3u8,
+ {
+ let c: u32 = unsafe { ::std::mem::transmute(c) };
+ c as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ }
+}
+///
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
+pub struct second_bitfield_struct {
+ pub _bindgen_align: [u32; 0],
+ pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+ pub __bindgen_padding_0: [u8; 3usize],
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of second_bitfield_struct",
+ ][::std::mem::size_of::() - 4usize];
+ [
+ "Alignment of second_bitfield_struct",
+ ][::std::mem::align_of::() - 4usize];
+};
+impl second_bitfield_struct {
+ #[inline]
+ pub fn x(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 4u8) as u32) }
+ }
+ #[inline]
+ pub fn set_x(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 4u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn x_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 4u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_x_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 0usize,
+ 4u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn y(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u32) }
+ }
+ #[inline]
+ pub fn set_y(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(4usize, 4u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn y_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 4usize, 4u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_y_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 4usize,
+ 4u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(
+ x: ::std::os::raw::c_uint,
+ y: ::std::os::raw::c_uint,
+ ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
+ __bindgen_bitfield_unit
+ .set(
+ 0usize,
+ 4u8,
+ {
+ let x: u32 = unsafe { ::std::mem::transmute(x) };
+ x as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ .set(
+ 4usize,
+ 4u8,
+ {
+ let y: u32 = unsafe { ::std::mem::transmute(y) };
+ y as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ }
+}
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default)]
+pub struct third_bitfield_struct {
+ pub _bindgen_align: [u32; 0],
+ pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+ pub __bindgen_padding_0: [u8; 3usize],
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of third_bitfield_struct",
+ ][::std::mem::size_of::() - 4usize];
+ [
+ "Alignment of third_bitfield_struct",
+ ][::std::mem::align_of::() - 4usize];
+};
+impl third_bitfield_struct {
+ #[inline]
+ pub fn z(&self) -> ::std::os::raw::c_uint {
+ unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 8u8) as u32) }
+ }
+ #[inline]
+ pub fn set_z(&mut self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ self._bitfield_1.set(0usize, 8u8, val as u64)
+ }
+ }
+ #[inline]
+ pub unsafe fn z_raw(this: *const Self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 8u8)
+ as u32,
+ )
+ }
+ }
+ #[inline]
+ pub unsafe fn set_z_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
+ unsafe {
+ let val: u32 = ::std::mem::transmute(val);
+ <__BindgenBitfieldUnit<
+ [u8; 1usize],
+ >>::raw_set(
+ ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+ 0usize,
+ 8u8,
+ val as u64,
+ )
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(
+ z: ::std::os::raw::c_uint,
+ ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
+ __bindgen_bitfield_unit
+ .set(
+ 0usize,
+ 8u8,
+ {
+ let z: u32 = unsafe { ::std::mem::transmute(z) };
+ z as u64
+ },
+ );
+ __bindgen_bitfield_unit
+ }
+}
diff --git a/bindgen-tests/tests/expectations/tests/blocklist-file.rs b/bindgen-tests/tests/expectations/tests/blocklist-file.rs
index 4056ef4d2c..9b5d979731 100644
--- a/bindgen-tests/tests/expectations/tests/blocklist-file.rs
+++ b/bindgen-tests/tests/expectations/tests/blocklist-file.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct SizedIntegers {
pub x: u8,
pub y: u16,
@@ -21,7 +21,7 @@ const _: () = {
][::std::mem::offset_of!(SizedIntegers, z) - 4usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct StructWithBlocklistedFwdDecl {
pub b: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/blocklist-function.rs b/bindgen-tests/tests/expectations/tests/blocklist-function.rs
index 65b66b2ac2..d75c207bb5 100644
--- a/bindgen-tests/tests/expectations/tests/blocklist-function.rs
+++ b/bindgen-tests/tests/expectations/tests/blocklist-function.rs
@@ -16,7 +16,7 @@ pub mod root {
}
}
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct C {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/blocklist-methods.rs b/bindgen-tests/tests/expectations/tests/blocklist-methods.rs
index c89cadb3d5..60a6c8e5c8 100644
--- a/bindgen-tests/tests/expectations/tests/blocklist-methods.rs
+++ b/bindgen-tests/tests/expectations/tests/blocklist-methods.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/blocklist_bitfield_unit.rs b/bindgen-tests/tests/expectations/tests/blocklist_bitfield_unit.rs
index 77c263e3cc..985c67f9f8 100644
--- a/bindgen-tests/tests/expectations/tests/blocklist_bitfield_unit.rs
+++ b/bindgen-tests/tests/expectations/tests/blocklist_bitfield_unit.rs
@@ -3,7 +3,7 @@
mod bitfields;
use bitfields::*;
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct C {
pub x: ::std::os::raw::c_uchar,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
@@ -94,7 +94,7 @@ impl C {
b1: ::std::os::raw::c_uint,
b2: ::std::os::raw::c_uint,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/blocks-signature.rs b/bindgen-tests/tests/expectations/tests/blocks-signature.rs
index 93cf28e009..88ea0aafe1 100644
--- a/bindgen-tests/tests/expectations/tests/blocks-signature.rs
+++ b/bindgen-tests/tests/expectations/tests/blocks-signature.rs
@@ -23,7 +23,7 @@ unsafe extern "C" {
pub fn foo_ptr(arg1: *mut _bindgen_ty_id_56) -> bool;
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct contains_block_pointers {
pub val: contains_block_pointers__bindgen_ty_id_61,
pub ptr_val: *mut _bindgen_ty_id_68,
diff --git a/bindgen-tests/tests/expectations/tests/blocks.rs b/bindgen-tests/tests/expectations/tests/blocks.rs
index 4f51113c4b..0c8c929bcd 100644
--- a/bindgen-tests/tests/expectations/tests/blocks.rs
+++ b/bindgen-tests/tests/expectations/tests/blocks.rs
@@ -22,7 +22,7 @@ unsafe extern "C" {
pub fn foo_ptr(arg1: *mut *mut ::std::os::raw::c_void) -> bool;
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct contains_block_pointers {
pub val: *mut ::std::os::raw::c_void,
pub ptr_val: *mut *mut ::std::os::raw::c_void,
diff --git a/bindgen-tests/tests/expectations/tests/bug-1529681.rs b/bindgen-tests/tests/expectations/tests/bug-1529681.rs
index bd59c1971f..e1c22e9263 100644
--- a/bindgen-tests/tests/expectations/tests/bug-1529681.rs
+++ b/bindgen-tests/tests/expectations/tests/bug-1529681.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct BrowsingContext {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/c-empty-layout.rs b/bindgen-tests/tests/expectations/tests/c-empty-layout.rs
index 709a9a59d8..38b339686e 100644
--- a/bindgen-tests/tests/expectations/tests/c-empty-layout.rs
+++ b/bindgen-tests/tests/expectations/tests/c-empty-layout.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
diff --git a/bindgen-tests/tests/expectations/tests/c_naming.rs b/bindgen-tests/tests/expectations/tests/c_naming.rs
index 38e63ce874..75c4061cea 100644
--- a/bindgen-tests/tests/expectations/tests/c_naming.rs
+++ b/bindgen-tests/tests/expectations/tests/c_naming.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct struct_a {
pub a: ::std::os::raw::c_int,
}
@@ -12,7 +12,7 @@ const _: () = {
};
pub type a = *const struct_a;
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union union_b {
pub a: ::std::os::raw::c_int,
pub b: ::std::os::raw::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/call-conv-field.rs b/bindgen-tests/tests/expectations/tests/call-conv-field.rs
index 8f0502a435..97ee606378 100644
--- a/bindgen-tests/tests/expectations/tests/call-conv-field.rs
+++ b/bindgen-tests/tests/expectations/tests/call-conv-field.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#![cfg(not(test))]
#[repr(C)]
-#[derive(Default, Copy, Clone)]
+#[derive(Clone, Copy, Default)]
pub struct JNINativeInterface_ {
pub GetVersion: ::std::option::Option<
unsafe extern "stdcall" fn(
diff --git a/bindgen-tests/tests/expectations/tests/canonical-types.rs b/bindgen-tests/tests/expectations/tests/canonical-types.rs
index 81d2e488a2..1cf98d2076 100644
--- a/bindgen-tests/tests/expectations/tests/canonical-types.rs
+++ b/bindgen-tests/tests/expectations/tests/canonical-types.rs
@@ -1,11 +1,11 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct ClassA {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassA_ClassAInner {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub x: *mut T,
@@ -20,17 +20,17 @@ impl Default for ClassA_ClassAInner {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct ClassB {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct ClassC {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassC_ClassCInnerB {
pub cache: *mut ClassC_ClassCInnerA,
}
@@ -44,7 +44,7 @@ impl Default for ClassC_ClassCInnerB {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassC_ClassCInnerA {
pub member: *mut ClassC_ClassCInnerB,
}
@@ -58,7 +58,7 @@ impl Default for ClassC_ClassCInnerA {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassC_ClassCInnerCRTP {
pub _address: u8,
}
@@ -72,7 +72,7 @@ impl Default for ClassC_ClassCInnerCRTP {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassD {
pub _address: u8,
}
@@ -100,7 +100,7 @@ const _: () = {
][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassCInnerCRTP {
pub _address: u8,
}
@@ -128,7 +128,7 @@ const _: () = {
][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassAInner {
pub x: *mut ClassCInnerA,
}
@@ -148,7 +148,7 @@ impl Default for ClassAInner {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassCInnerA {
pub member: *mut ClassCInnerB,
}
@@ -170,7 +170,7 @@ impl Default for ClassCInnerA {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct ClassCInnerB {
pub cache: *mut ClassCInnerA,
}
diff --git a/bindgen-tests/tests/expectations/tests/canonical_path_without_namespacing.rs b/bindgen-tests/tests/expectations/tests/canonical_path_without_namespacing.rs
index 613da3060f..630eefc82c 100644
--- a/bindgen-tests/tests/expectations/tests/canonical_path_without_namespacing.rs
+++ b/bindgen-tests/tests/expectations/tests/canonical_path_without_namespacing.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Bar {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/char.rs b/bindgen-tests/tests/expectations/tests/char.rs
index 61a81269d7..5246e2b42e 100644
--- a/bindgen-tests/tests/expectations/tests/char.rs
+++ b/bindgen-tests/tests/expectations/tests/char.rs
@@ -3,7 +3,7 @@ pub type Char = ::std::os::raw::c_char;
pub type SChar = ::std::os::raw::c_schar;
pub type UChar = ::std::os::raw::c_uchar;
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct Test {
pub ch: ::std::os::raw::c_char,
pub u: ::std::os::raw::c_uchar,
diff --git a/bindgen-tests/tests/expectations/tests/class.rs b/bindgen-tests/tests/expectations/tests/class.rs
index 98ee43b374..4e94ec6bbb 100644
--- a/bindgen-tests/tests/expectations/tests/class.rs
+++ b/bindgen-tests/tests/expectations/tests/class.rs
@@ -30,7 +30,7 @@ impl ::std::fmt::Debug for __IncompleteArrayField {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct C {
pub a: ::std::os::raw::c_int,
pub big_array: [::std::os::raw::c_char; 33usize],
@@ -236,7 +236,7 @@ const _: () = {
) - 4usize];
};
#[repr(C)]
-#[derive(Debug, Default, Hash, PartialOrd, Ord, PartialEq, Eq)]
+#[derive(Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct WithDtor {
pub b: ::std::os::raw::c_int,
}
@@ -277,7 +277,7 @@ impl Default for IncompleteArrayNonCopiable {
}
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union Union {
pub d: f32,
pub i: ::std::os::raw::c_int,
@@ -299,7 +299,7 @@ impl Default for Union {
}
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub struct WithUnion {
pub data: Union,
}
@@ -321,7 +321,7 @@ impl Default for WithUnion {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RealAbstractionWithTonsOfMethods {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_nested.rs b/bindgen-tests/tests/expectations/tests/class_nested.rs
index 080f5968bc..ae00919a93 100644
--- a/bindgen-tests/tests/expectations/tests/class_nested.rs
+++ b/bindgen-tests/tests/expectations/tests/class_nested.rs
@@ -1,11 +1,11 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct A {
pub member_a: ::std::os::raw::c_int,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct A_B {
pub member_b: ::std::os::raw::c_int,
}
@@ -16,7 +16,7 @@ const _: () = {
["Offset of field: A_B::member_b"][::std::mem::offset_of!(A_B, member_b) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct A_D {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub foo: T,
@@ -37,7 +37,7 @@ const _: () = {
["Offset of field: A::member_a"][::std::mem::offset_of!(A, member_a) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct A_C {
pub baz: ::std::os::raw::c_int,
}
@@ -63,7 +63,7 @@ unsafe extern "C" {
pub static mut baz: A_D<::std::os::raw::c_int>;
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct D {
pub member: A_B,
}
@@ -74,13 +74,13 @@ const _: () = {
["Offset of field: D::member"][::std::mem::offset_of!(D, member) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Templated {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub member: T,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Templated_Templated_inner {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub member_ptr: *mut T,
diff --git a/bindgen-tests/tests/expectations/tests/class_no_members.rs b/bindgen-tests/tests/expectations/tests/class_no_members.rs
index c50da6a02d..80eb9890fb 100644
--- a/bindgen-tests/tests/expectations/tests/class_no_members.rs
+++ b/bindgen-tests/tests/expectations/tests/class_no_members.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct whatever {
pub _address: u8,
}
@@ -10,7 +10,7 @@ const _: () = {
["Alignment of whatever"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct whatever_child {
pub _address: u8,
}
@@ -20,7 +20,7 @@ const _: () = {
["Alignment of whatever_child"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct whatever_child_with_member {
pub m_member: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_static.rs b/bindgen-tests/tests/expectations/tests/class_static.rs
index d448165d62..df7e28c258 100644
--- a/bindgen-tests/tests/expectations/tests/class_static.rs
+++ b/bindgen-tests/tests/expectations/tests/class_static.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct MyClass {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_static_const.rs b/bindgen-tests/tests/expectations/tests/class_static_const.rs
index d628239c4c..df9fd34048 100644
--- a/bindgen-tests/tests/expectations/tests/class_static_const.rs
+++ b/bindgen-tests/tests/expectations/tests/class_static_const.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct A {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_use_as.rs b/bindgen-tests/tests/expectations/tests/class_use_as.rs
index ec898ff7eb..68b29dd8d0 100644
--- a/bindgen-tests/tests/expectations/tests/class_use_as.rs
+++ b/bindgen-tests/tests/expectations/tests/class_use_as.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
///
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct whatever {
pub replacement: ::std::os::raw::c_int,
}
@@ -14,7 +14,7 @@ const _: () = {
][::std::mem::offset_of!(whatever, replacement) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct container {
pub c: whatever,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_with_dtor.rs b/bindgen-tests/tests/expectations/tests/class_with_dtor.rs
index aa99f42468..b149c65338 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_dtor.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_dtor.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Hash, PartialEq, Eq)]
+#[derive(Debug, Eq, Hash, PartialEq)]
pub struct HandleWithDtor {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub ptr: *mut T,
@@ -16,7 +16,7 @@ impl Default for HandleWithDtor {
}
pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>;
#[repr(C)]
-#[derive(Debug, Hash, PartialEq, Eq)]
+#[derive(Debug, Eq, Hash, PartialEq)]
pub struct WithoutDtor {
pub shouldBeWithDtor: HandleValue,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_with_enum.rs b/bindgen-tests/tests/expectations/tests/class_with_enum.rs
index ca1806357c..5959dbfb6b 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_enum.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_enum.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct A {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/class_with_inner_struct.rs b/bindgen-tests/tests/expectations/tests/class_with_inner_struct.rs
index 710026c72f..2f3bb4cbb0 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_inner_struct.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_inner_struct.rs
@@ -1,13 +1,13 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub struct A {
pub c: ::std::os::raw::c_uint,
pub named_union: A__bindgen_ty_1,
pub __bindgen_anon_1: A__bindgen_ty_2,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct A_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -22,7 +22,7 @@ const _: () = {
["Offset of field: A_Segment::end"][::std::mem::offset_of!(A_Segment, end) - 4usize];
};
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union A__bindgen_ty_1 {
pub f: ::std::os::raw::c_int,
}
@@ -44,7 +44,7 @@ impl Default for A__bindgen_ty_1 {
}
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union A__bindgen_ty_2 {
pub d: ::std::os::raw::c_int,
}
@@ -82,12 +82,12 @@ impl Default for A {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct B {
pub d: ::std::os::raw::c_uint,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct B_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -116,19 +116,19 @@ pub enum StepSyntax {
FunctionalWithEndKeyword = 3,
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub struct C {
pub d: ::std::os::raw::c_uint,
pub __bindgen_anon_1: C__bindgen_ty_1,
}
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Clone, Copy)]
pub union C__bindgen_ty_1 {
pub mFunc: C__bindgen_ty_1__bindgen_ty_1,
pub __bindgen_anon_1: C__bindgen_ty_1__bindgen_ty_2,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, PartialEq)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct C__bindgen_ty_1__bindgen_ty_1 {
pub mX1: f32,
pub mY1: f32,
@@ -157,7 +157,7 @@ const _: () = {
][::std::mem::offset_of!(C__bindgen_ty_1__bindgen_ty_1, mY2) - 12usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct C__bindgen_ty_1__bindgen_ty_2 {
pub mStepSyntax: StepSyntax,
pub mSteps: ::std::os::raw::c_uint,
@@ -204,7 +204,7 @@ impl Default for C__bindgen_ty_1 {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub struct C_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs
index 73f2b55cc3..b25ca06462 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub type AnotherInt = ::std::os::raw::c_int;
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct C {
pub c: C_MyInt,
pub ptr: *mut C_MyInt,
@@ -65,7 +65,7 @@ impl C {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct D {
pub _base: C,
pub ptr: *mut C_MyInt,
diff --git a/bindgen-tests/tests/expectations/tests/comment-indent.rs b/bindgen-tests/tests/expectations/tests/comment-indent.rs
index 72b167d00c..d93d824e93 100644
--- a/bindgen-tests/tests/expectations/tests/comment-indent.rs
+++ b/bindgen-tests/tests/expectations/tests/comment-indent.rs
@@ -7,7 +7,7 @@ pub mod root {
This class is really really interesting, look!*/
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
@@ -15,7 +15,7 @@ pub mod root {
This class is not so interesting, but worth a bit of docs too!*/
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Foo_Bar {
pub _address: u8,
}
@@ -35,7 +35,7 @@ pub mod root {
/** I'm in a namespace, and thus I may be on a rust module, most of the time.
My documentation is pretty extensive, I guess.*/
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Baz {
/** This member is plain awesome, just amazing.
@@ -58,7 +58,7 @@ pub mod root {
a rust module, except when the relevant option is specified. Also, this
comment shouldn't be misaligned.*/
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct InInlineNS {
pub _address: u8,
}
@@ -68,7 +68,7 @@ pub mod root {
["Alignment of InInlineNS"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
- #[derive(Debug, Default, Copy, Clone)]
+ #[derive(Clone, Copy, Debug, Default)]
pub struct Bazz {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/complex.rs b/bindgen-tests/tests/expectations/tests/complex.rs
index 233b86ea36..62b39933cd 100644
--- a/bindgen-tests/tests/expectations/tests/complex.rs
+++ b/bindgen-tests/tests/expectations/tests/complex.rs
@@ -1,12 +1,12 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[repr(C)]
pub struct __BindgenComplex {
pub re: T,
pub im: T,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, PartialEq)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct TestDouble {
pub mMember: __BindgenComplex,
}
@@ -19,7 +19,7 @@ const _: () = {
][::std::mem::offset_of!(TestDouble, mMember) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct TestDoublePtr {
pub mMember: *mut __BindgenComplex,
}
@@ -41,7 +41,7 @@ impl Default for TestDoublePtr {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone, PartialEq)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct TestFloat {
pub mMember: __BindgenComplex,
}
@@ -54,7 +54,7 @@ const _: () = {
][::std::mem::offset_of!(TestFloat, mMember) - 0usize];
};
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct TestFloatPtr {
pub mMember: *mut __BindgenComplex,
}
diff --git a/bindgen-tests/tests/expectations/tests/complex_global.rs b/bindgen-tests/tests/expectations/tests/complex_global.rs
index c818df676e..e3aa54514a 100644
--- a/bindgen-tests/tests/expectations/tests/complex_global.rs
+++ b/bindgen-tests/tests/expectations/tests/complex_global.rs
@@ -1,5 +1,4 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct __BindgenComplex {
pub re: T,
diff --git a/bindgen-tests/tests/expectations/tests/complex_union_derives.rs b/bindgen-tests/tests/expectations/tests/complex_union_derives.rs
new file mode 100644
index 0000000000..a783e00c4d
--- /dev/null
+++ b/bindgen-tests/tests/expectations/tests/complex_union_derives.rs
@@ -0,0 +1,58 @@
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+#[repr(C)]
+pub struct __BindgenComplex {
+ pub re: T,
+ pub im: T,
+}
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+pub struct first_complex_struct {
+ pub a: __BindgenComplex,
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of first_complex_struct",
+ ][::std::mem::size_of::() - 16usize];
+ [
+ "Alignment of first_complex_struct",
+ ][::std::mem::align_of::() - 8usize];
+ [
+ "Offset of field: first_complex_struct::a",
+ ][::std::mem::offset_of!(first_complex_struct, a) - 0usize];
+};
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+pub struct second_complex_struct {
+ pub b: __BindgenComplex,
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of second_complex_struct",
+ ][::std::mem::size_of::() - 8usize];
+ [
+ "Alignment of second_complex_struct",
+ ][::std::mem::align_of::() - 4usize];
+ [
+ "Offset of field: second_complex_struct::b",
+ ][::std::mem::offset_of!(second_complex_struct, b) - 0usize];
+};
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+pub struct third_complex_struct {
+ pub c: __BindgenComplex,
+}
+#[allow(clippy::unnecessary_operation, clippy::identity_op)]
+const _: () = {
+ [
+ "Size of third_complex_struct",
+ ][::std::mem::size_of::() - 16usize];
+ [
+ "Alignment of third_complex_struct",
+ ][::std::mem::align_of::() - 8usize];
+ [
+ "Offset of field: third_complex_struct::c",
+ ][::std::mem::offset_of!(third_complex_struct, c) - 0usize];
+};
diff --git a/bindgen-tests/tests/expectations/tests/const-const-mut-ptr.rs b/bindgen-tests/tests/expectations/tests/const-const-mut-ptr.rs
index 72a34da105..25f5d1fe1a 100644
--- a/bindgen-tests/tests/expectations/tests/const-const-mut-ptr.rs
+++ b/bindgen-tests/tests/expectations/tests/const-const-mut-ptr.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct foo {
pub bar: *const *const *mut *const ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/const_array_typedef.rs b/bindgen-tests/tests/expectations/tests/const_array_typedef.rs
index 034856d359..946b241aec 100644
--- a/bindgen-tests/tests/expectations/tests/const_array_typedef.rs
+++ b/bindgen-tests/tests/expectations/tests/const_array_typedef.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct strct {
pub field: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/const_bool.rs b/bindgen-tests/tests/expectations/tests/const_bool.rs
index 2cbab47390..42168dfd7e 100644
--- a/bindgen-tests/tests/expectations/tests/const_bool.rs
+++ b/bindgen-tests/tests/expectations/tests/const_bool.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub const k: bool = true;
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct A {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/const_enum_unnamed.rs b/bindgen-tests/tests/expectations/tests/const_enum_unnamed.rs
index f49d825224..aaca48baaa 100644
--- a/bindgen-tests/tests/expectations/tests/const_enum_unnamed.rs
+++ b/bindgen-tests/tests/expectations/tests/const_enum_unnamed.rs
@@ -8,7 +8,7 @@ pub enum _bindgen_ty_1 {
FOO_BAZ = 1,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/const_tparam.rs b/bindgen-tests/tests/expectations/tests/const_tparam.rs
index c6b16a8959..f885ecd89a 100644
--- a/bindgen-tests/tests/expectations/tests/const_tparam.rs
+++ b/bindgen-tests/tests/expectations/tests/const_tparam.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct C {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub foo: *const T,
diff --git a/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs b/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs
index 968ec350aa..b609710f8e 100644
--- a/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs
+++ b/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs
@@ -1,16 +1,16 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Test {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Outer {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Outer_Inner {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/constified-enum-module-overflow.rs b/bindgen-tests/tests/expectations/tests/constified-enum-module-overflow.rs
index e5eada9abc..0fa5784ae5 100644
--- a/bindgen-tests/tests/expectations/tests/constified-enum-module-overflow.rs
+++ b/bindgen-tests/tests/expectations/tests/constified-enum-module-overflow.rs
@@ -1,17 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct B {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct C {
pub _address: u8,
}
pub type C_U = B;
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct A {
pub u: B,
}
diff --git a/bindgen-tests/tests/expectations/tests/constify-all-enums.rs b/bindgen-tests/tests/expectations/tests/constify-all-enums.rs
index 7913454b56..c33eceae43 100644
--- a/bindgen-tests/tests/expectations/tests/constify-all-enums.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-all-enums.rs
@@ -4,7 +4,7 @@ pub const foo_SHOULD_BE: foo = 1;
pub const foo_A_CONSTANT: foo = 2;
pub type foo = ::std::os::raw::c_uint;
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct bar {
pub this_should_work: foo,
}
diff --git a/bindgen-tests/tests/expectations/tests/constify-module-enums-basic.rs b/bindgen-tests/tests/expectations/tests/constify-module-enums-basic.rs
index aad696d074..331e3c18d4 100644
--- a/bindgen-tests/tests/expectations/tests/constify-module-enums-basic.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-module-enums-basic.rs
@@ -10,7 +10,7 @@ pub mod foo {
pub use self::foo::Type as foo_alias1;
pub use self::foo_alias1 as foo_alias2;
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct bar {
pub this_should_work: foo::Type,
}
diff --git a/bindgen-tests/tests/expectations/tests/constify-module-enums-namespace.rs b/bindgen-tests/tests/expectations/tests/constify-module-enums-namespace.rs
index cdf6e7ebb4..b32973914f 100644
--- a/bindgen-tests/tests/expectations/tests/constify-module-enums-namespace.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-module-enums-namespace.rs
@@ -22,7 +22,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::super::root;
#[repr(C)]
- #[derive(Debug, Copy, Clone)]
+ #[derive(Clone, Copy, Debug)]
pub struct bar {
pub this_should_work: root::ns1::ns2::foo::Type,
}
diff --git a/bindgen-tests/tests/expectations/tests/constify-module-enums-shadow-name.rs b/bindgen-tests/tests/expectations/tests/constify-module-enums-shadow-name.rs
index 987f4463a2..e521588ad0 100644
--- a/bindgen-tests/tests/expectations/tests/constify-module-enums-shadow-name.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-module-enums-shadow-name.rs
@@ -9,7 +9,7 @@ pub mod foo {
pub const Type__: Type = 3;
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct bar {
pub member: foo::Type,
}
diff --git a/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-alias.rs b/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-alias.rs
index 5f7b9ede4a..711963a496 100644
--- a/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-alias.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-alias.rs
@@ -11,7 +11,7 @@ pub use self::Foo::Type as Foo_alias1;
pub use self::Foo_alias1 as Foo_alias2;
pub use self::Foo_alias2 as Foo_alias3;
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct Bar {
pub baz1: Foo::Type,
pub baz2: Foo_alias1,
diff --git a/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs b/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs
index dc59f5fc1d..aa64ec7cd5 100644
--- a/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs
@@ -7,7 +7,7 @@ pub mod one_Foo {
pub const Variant2: Type = 1;
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct Bar {
pub baz1: one_Foo::Type,
pub baz2: *mut one_Foo::Type,
diff --git a/bindgen-tests/tests/expectations/tests/constify-module-enums-types.rs b/bindgen-tests/tests/expectations/tests/constify-module-enums-types.rs
index a4a69fd72d..b5add36d66 100644
--- a/bindgen-tests/tests/expectations/tests/constify-module-enums-types.rs
+++ b/bindgen-tests/tests/expectations/tests/constify-module-enums-types.rs
@@ -48,7 +48,7 @@ pub use self::anon_enum::Type as anon_enum_alias1;
pub use self::anon_enum_alias1 as anon_enum_alias2;
pub use self::anon_enum_alias2 as anon_enum_alias3;
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct bar {
pub member1: foo::Type,
pub member2: foo_alias1,
@@ -86,7 +86,7 @@ impl Default for bar {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct Baz {
pub member1: ns2_Foo::Type,
}
@@ -113,7 +113,7 @@ pub mod one_Foo {
pub const Variant2: Type = 1;
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct Bar {
pub baz: *mut one_Foo::Type,
}
@@ -149,7 +149,7 @@ unsafe extern "C" {
) -> *mut foo_alias1;
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct Thing {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub thing: T,
diff --git a/bindgen-tests/tests/expectations/tests/constructor-tp.rs b/bindgen-tests/tests/expectations/tests/constructor-tp.rs
index 2585311d29..1e9dfa8080 100644
--- a/bindgen-tests/tests/expectations/tests/constructor-tp.rs
+++ b/bindgen-tests/tests/expectations/tests/constructor-tp.rs
@@ -1,11 +1,11 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Bar {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/constructors.rs b/bindgen-tests/tests/expectations/tests/constructors.rs
index 45c29e61e5..fd6515b019 100644
--- a/bindgen-tests/tests/expectations/tests/constructors.rs
+++ b/bindgen-tests/tests/expectations/tests/constructors.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct TestOverload {
pub _address: u8,
}
@@ -35,7 +35,7 @@ impl TestOverload {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct TestPublicNoArgs {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs
index 5dbda00007..f0e84ccc3b 100644
--- a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs
+++ b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct TestOverload {
pub _address: u8,
}
@@ -37,7 +37,7 @@ impl TestOverload {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct TestPublicNoArgs {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/contains-vs-inherits-zero-sized.rs b/bindgen-tests/tests/expectations/tests/contains-vs-inherits-zero-sized.rs
index 3362280843..aca31d374d 100644
--- a/bindgen-tests/tests/expectations/tests/contains-vs-inherits-zero-sized.rs
+++ b/bindgen-tests/tests/expectations/tests/contains-vs-inherits-zero-sized.rs
@@ -1,7 +1,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
/// This should get an `_address` byte.
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Empty {
pub _address: u8,
}
@@ -13,7 +13,7 @@ const _: () = {
/** This should not get an `_address` byte, so `sizeof(Inherits)` should be
`1`.*/
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Inherits {
pub b: bool,
}
@@ -26,7 +26,7 @@ const _: () = {
/** This should not get an `_address` byte, but contains `Empty` which *does* get
one, so `sizeof(Contains)` should be `1 + 1`.*/
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Contains {
pub empty: Empty,
pub b: bool,
diff --git a/bindgen-tests/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/bindgen-tests/tests/expectations/tests/convert-cpp-comment-to-rust.rs
index 96f9e6fd2a..286c42c761 100644
--- a/bindgen-tests/tests/expectations/tests/convert-cpp-comment-to-rust.rs
+++ b/bindgen-tests/tests/expectations/tests/convert-cpp-comment-to-rust.rs
@@ -2,7 +2,7 @@
pub type mbedtls_mpi_uint = ::std::os::raw::c_uint;
/// \brief MPI structure
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct mbedtls_mpi {
///< integer sign
pub s: ::std::os::raw::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/convert-floats.rs b/bindgen-tests/tests/expectations/tests/convert-floats.rs
index 9ca939f7c5..4cc707d402 100644
--- a/bindgen-tests/tests/expectations/tests/convert-floats.rs
+++ b/bindgen-tests/tests/expectations/tests/convert-floats.rs
@@ -1,12 +1,12 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
+#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct __BindgenComplex {
pub re: T,
pub im: T,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct foo {
pub bar: ::std::os::raw::c_float,
pub baz: ::std::os::raw::c_float,
diff --git a/bindgen-tests/tests/expectations/tests/cpp-empty-layout.rs b/bindgen-tests/tests/expectations/tests/cpp-empty-layout.rs
index 551dff82cf..63beda5753 100644
--- a/bindgen-tests/tests/expectations/tests/cpp-empty-layout.rs
+++ b/bindgen-tests/tests/expectations/tests/cpp-empty-layout.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/crtp.rs b/bindgen-tests/tests/expectations/tests/crtp.rs
index 68397041b7..b367c2d8de 100644
--- a/bindgen-tests/tests/expectations/tests/crtp.rs
+++ b/bindgen-tests/tests/expectations/tests/crtp.rs
@@ -1,11 +1,11 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Base {
pub _address: u8,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Derived {
pub _address: u8,
}
diff --git a/bindgen-tests/tests/expectations/tests/ctypes-prefix-path.rs b/bindgen-tests/tests/expectations/tests/ctypes-prefix-path.rs
index 5f947f9cea..0042a1d06c 100644
--- a/bindgen-tests/tests/expectations/tests/ctypes-prefix-path.rs
+++ b/bindgen-tests/tests/expectations/tests/ctypes-prefix-path.rs
@@ -7,7 +7,7 @@ mod libc {
}
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct foo {
pub a: libc::foo::c_int,
pub b: libc::foo::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/dash_language.rs b/bindgen-tests/tests/expectations/tests/dash_language.rs
index f405a35604..7b9251994a 100644
--- a/bindgen-tests/tests/expectations/tests/dash_language.rs
+++ b/bindgen-tests/tests/expectations/tests/dash_language.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Foo {
pub bar: ::std::os::raw::c_int,
}
diff --git a/bindgen-tests/tests/expectations/tests/default-template-parameter.rs b/bindgen-tests/tests/expectations/tests/default-template-parameter.rs
index 67f8a486de..712f149394 100644
--- a/bindgen-tests/tests/expectations/tests/default-template-parameter.rs
+++ b/bindgen-tests/tests/expectations/tests/default-template-parameter.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug)]
pub struct Foo {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>,
diff --git a/bindgen-tests/tests/expectations/tests/default_visibility_crate.rs b/bindgen-tests/tests/expectations/tests/default_visibility_crate.rs
index aeefb2e0f9..57b27ae510 100644
--- a/bindgen-tests/tests/expectations/tests/default_visibility_crate.rs
+++ b/bindgen-tests/tests/expectations/tests/default_visibility_crate.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,18 +145,20 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Point {
pub(crate) x: ::std::os::raw::c_int,
pub(crate) y: ::std::os::raw::c_int,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Color {
pub(crate) _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
}
@@ -268,7 +274,7 @@ impl Color {
g: ::std::os::raw::c_char,
b: ::std::os::raw::c_char,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/default_visibility_private.rs b/bindgen-tests/tests/expectations/tests/default_visibility_private.rs
index dceed75e36..70526ec704 100644
--- a/bindgen-tests/tests/expectations/tests/default_visibility_private.rs
+++ b/bindgen-tests/tests/expectations/tests/default_visibility_private.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,18 +145,20 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Point {
x: ::std::os::raw::c_int,
y: ::std::os::raw::c_int,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Color {
_bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
}
@@ -268,7 +274,7 @@ impl Color {
g: ::std::os::raw::c_char,
b: ::std::os::raw::c_char,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/default_visibility_private_respects_cxx_access_spec.rs b/bindgen-tests/tests/expectations/tests/default_visibility_private_respects_cxx_access_spec.rs
index f43be84bb0..ae0267d8d1 100644
--- a/bindgen-tests/tests/expectations/tests/default_visibility_private_respects_cxx_access_spec.rs
+++ b/bindgen-tests/tests/expectations/tests/default_visibility_private_respects_cxx_access_spec.rs
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
@@ -32,12 +34,12 @@ where
Self::extract_bit(byte, index)
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- *(core::ptr::addr_of!((*this).storage) as *const u8)
- .offset(byte_index as isize)
+ *core::ptr::addr_of!((*this).storage).cast::().add(byte_index)
};
Self::extract_bit(byte, index)
}
@@ -59,12 +61,12 @@ where
*byte = Self::change_bit(*byte, index, val);
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
debug_assert!(index / 8 < core::mem::size_of::());
let byte_index = index / 8;
let byte = unsafe {
- (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
- .offset(byte_index as isize)
+ core::ptr::addr_of_mut!((*this).storage).cast::().add(byte_index)
};
unsafe { *byte = Self::change_bit(*byte, index, val) };
}
@@ -89,6 +91,7 @@ where
val
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -127,6 +130,7 @@ where
}
}
#[inline]
+ #[allow(dead_code)]
pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < core::mem::size_of::());
@@ -141,18 +145,20 @@ where
} else {
i
};
- unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
+ unsafe {
+ Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+ };
}
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Point {
pub x: ::std::os::raw::c_int,
pub y: ::std::os::raw::c_int,
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct Color {
_bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
}
@@ -268,7 +274,7 @@ impl Color {
g: ::std::os::raw::c_char,
b: ::std::os::raw::c_char,
) -> __BindgenBitfieldUnit<[u8; 1usize]> {
- let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+ let mut __bindgen_bitfield_unit = __BindgenBitfieldUnit::new([0u8; 1usize]);
__bindgen_bitfield_unit
.set(
0usize,
diff --git a/bindgen-tests/tests/expectations/tests/deleted-function.rs b/bindgen-tests/tests/expectations/tests/deleted-function.rs
index fc8588121f..16b1131667 100644
--- a/bindgen-tests/tests/expectations/tests/deleted-function.rs
+++ b/bindgen-tests/tests/expectations/tests/deleted-function.rs
@@ -1,6 +1,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct A {
pub _address: u8,
}
@@ -28,7 +28,7 @@ impl A {
}
}
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct B {
pub _address: u8,
}
@@ -38,7 +38,7 @@ const _: () = {
["Alignment of B"][::std::mem::align_of::() - 1usize];
};
#[repr(C)]
-#[derive(Debug, Default, Copy, Clone)]
+#[derive(Clone, Copy, Debug, Default)]
pub struct C {
pub _address: u8,
}
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 7fa8bc41ab..7bb4d69056 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
@@ -1,15 +1,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[repr(C)]
-#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Copy, Debug, PartialEq)]
pub struct __BindgenBitfieldUnit {
storage: Storage,
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit {
#[inline]
pub const fn new(storage: Storage) -> Self {
Self { storage }
}
}
+#[allow(unused_qualifications)]
impl __BindgenBitfieldUnit