summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/analysis/derive.rs6
-rw-r--r--tests/expectations/tests/derive-fn-ptr.rs23
-rw-r--r--tests/expectations/tests/func_ptr_in_struct.rs14
-rw-r--r--tests/expectations/tests/issue-1216-variadic-member.rs14
-rw-r--r--tests/expectations/tests/layout_cmdline_token.rs7
-rw-r--r--tests/expectations/tests/libclang-3.8/call-conv-field.rs19
-rw-r--r--tests/expectations/tests/libclang-3.9/call-conv-field.rs7
-rw-r--r--tests/expectations/tests/libclang-4/call-conv-field.rs7
-rw-r--r--tests/expectations/tests/libclang-5/call-conv-field.rs7
9 files changed, 35 insertions, 69 deletions
diff --git a/src/ir/analysis/derive.rs b/src/ir/analysis/derive.rs
index 1025150d..dbfe35a4 100644
--- a/src/ir/analysis/derive.rs
+++ b/src/ir/analysis/derive.rs
@@ -194,11 +194,7 @@ impl<'ctx> CannotDerive<'ctx> {
let inner_type =
self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
- if let DeriveTrait::Default = self.derive_trait {
- return CanDerive::No
- } else {
- return self.derive_trait.can_derive_fnptr(sig)
- }
+ return self.derive_trait.can_derive_fnptr(sig)
} else {
return self.derive_trait.can_derive_pointer();
}
diff --git a/tests/expectations/tests/derive-fn-ptr.rs b/tests/expectations/tests/derive-fn-ptr.rs
index 4b7105e9..7f158b3b 100644
--- a/tests/expectations/tests/derive-fn-ptr.rs
+++ b/tests/expectations/tests/derive-fn-ptr.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub type my_fun_t = ::std::option::Option<
unsafe extern "C" fn(
@@ -25,7 +28,7 @@ pub type my_fun_t = ::std::option::Option<
),
>;
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Default, Copy, Clone)]
pub struct Foo {
pub callback: my_fun_t,
}
@@ -52,11 +55,6 @@ fn bindgen_test_layout_Foo() {
)
);
}
-impl Default for Foo {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
pub type my_fun2_t = ::std::option::Option<
unsafe extern "C" fn(
arg1: ::std::os::raw::c_int,
@@ -74,7 +72,7 @@ pub type my_fun2_t = ::std::option::Option<
),
>;
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Bar {
pub callback: my_fun2_t,
}
@@ -101,8 +99,3 @@ fn bindgen_test_layout_Bar() {
)
);
}
-impl Default for Bar {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/tests/expectations/tests/func_ptr_in_struct.rs
index d66ce84d..f23984e8 100644
--- a/tests/expectations/tests/func_ptr_in_struct.rs
+++ b/tests/expectations/tests/func_ptr_in_struct.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@@ -8,7 +13,7 @@ pub enum baz {
__bindgen_cannot_repr_c_on_empty_enum = 0,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Foo {
pub bar: ::std::option::Option<
unsafe extern "C" fn(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) -> baz,
@@ -32,8 +37,3 @@ fn bindgen_test_layout_Foo() {
concat!("Offset of field: ", stringify!(Foo), "::", stringify!(bar))
);
}
-impl Default for Foo {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
diff --git a/tests/expectations/tests/issue-1216-variadic-member.rs b/tests/expectations/tests/issue-1216-variadic-member.rs
index 677993c0..e5099560 100644
--- a/tests/expectations/tests/issue-1216-variadic-member.rs
+++ b/tests/expectations/tests/issue-1216-variadic-member.rs
@@ -1,12 +1,17 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
extern "C" {
pub fn f(a: ::std::os::raw::c_int, ...);
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub f: ::std::option::Option<
unsafe extern "C" fn(
@@ -35,8 +40,3 @@ fn bindgen_test_layout_Foo() {
concat!("Offset of field: ", stringify!(Foo), "::", stringify!(f))
);
}
-impl Default for Foo {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs
index e8b72843..2ea596fc 100644
--- a/tests/expectations/tests/layout_cmdline_token.rs
+++ b/tests/expectations/tests/layout_cmdline_token.rs
@@ -72,7 +72,7 @@ pub type cmdline_parse_token_hdr_t = cmdline_token_hdr;
/// get_help() fills the dstbuf with the help for the token. It returns
/// -1 on error and 0 on success.
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Debug, Default, Copy, Clone)]
pub struct cmdline_token_ops {
/// parse(token ptr, buf, res pts, buf len)
pub parse: ::std::option::Option<
@@ -162,11 +162,6 @@ fn bindgen_test_layout_cmdline_token_ops() {
)
);
}
-impl Default for cmdline_token_ops {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum cmdline_numtype {
diff --git a/tests/expectations/tests/libclang-3.8/call-conv-field.rs b/tests/expectations/tests/libclang-3.8/call-conv-field.rs
index bad20dea..1800b635 100644
--- a/tests/expectations/tests/libclang-3.8/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-3.8/call-conv-field.rs
@@ -1,16 +1,18 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#![cfg(not(test))]
-
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Default, Copy, Clone)]
pub struct JNINativeInterface_ {
pub GetVersion: ::std::option::Option<
- unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void)
- -> ::std::os::raw::c_int,
+ unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
>,
pub __hack: ::std::os::raw::c_ulonglong,
}
@@ -47,11 +49,6 @@ fn bindgen_test_layout_JNINativeInterface_() {
)
);
}
-impl Default for JNINativeInterface_ {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
extern "C" {
#[link_name = "\u{1}_bar@0"]
pub fn bar();
diff --git a/tests/expectations/tests/libclang-3.9/call-conv-field.rs b/tests/expectations/tests/libclang-3.9/call-conv-field.rs
index 375eb9ad..6cf8ec5b 100644
--- a/tests/expectations/tests/libclang-3.9/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-3.9/call-conv-field.rs
@@ -6,7 +6,7 @@
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Default, Copy, Clone)]
pub struct JNINativeInterface_ {
pub GetVersion: ::std::option::Option<
unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void)
@@ -47,11 +47,6 @@ fn bindgen_test_layout_JNINativeInterface_() {
)
);
}
-impl Default for JNINativeInterface_ {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
extern "stdcall" {
#[link_name = "\u{1}_bar@0"]
pub fn bar();
diff --git a/tests/expectations/tests/libclang-4/call-conv-field.rs b/tests/expectations/tests/libclang-4/call-conv-field.rs
index 375eb9ad..6cf8ec5b 100644
--- a/tests/expectations/tests/libclang-4/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-4/call-conv-field.rs
@@ -6,7 +6,7 @@
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Default, Copy, Clone)]
pub struct JNINativeInterface_ {
pub GetVersion: ::std::option::Option<
unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void)
@@ -47,11 +47,6 @@ fn bindgen_test_layout_JNINativeInterface_() {
)
);
}
-impl Default for JNINativeInterface_ {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
extern "stdcall" {
#[link_name = "\u{1}_bar@0"]
pub fn bar();
diff --git a/tests/expectations/tests/libclang-5/call-conv-field.rs b/tests/expectations/tests/libclang-5/call-conv-field.rs
index e167e5eb..76712fe7 100644
--- a/tests/expectations/tests/libclang-5/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-5/call-conv-field.rs
@@ -9,7 +9,7 @@
#![cfg(not(test))]
#[repr(C)]
-#[derive(Copy, Clone)]
+#[derive(Default, Copy, Clone)]
pub struct JNINativeInterface_ {
pub GetVersion: ::std::option::Option<
unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
@@ -50,11 +50,6 @@ fn bindgen_test_layout_JNINativeInterface_() {
)
);
}
-impl Default for JNINativeInterface_ {
- fn default() -> Self {
- unsafe { ::std::mem::zeroed() }
- }
-}
extern "stdcall" {
#[link_name = "\u{1}_bar@0"]
pub fn bar();