summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/codegen/mod.rs15
-rw-r--r--tests/expectations/tests/anon_union.rs6
-rw-r--r--tests/expectations/tests/class.rs6
-rw-r--r--tests/expectations/tests/class_with_inner_struct.rs6
-rw-r--r--tests/expectations/tests/jsval_layout_opaque.rs6
-rw-r--r--tests/expectations/tests/struct_with_anon_union.rs6
-rw-r--r--tests/expectations/tests/struct_with_anon_unnamed_union.rs6
-rw-r--r--tests/expectations/tests/struct_with_nesting.rs6
-rw-r--r--tests/expectations/tests/typeref.rs6
-rw-r--r--tests/expectations/tests/union_dtor.rs6
-rw-r--r--tests/expectations/tests/union_fields.rs6
-rw-r--r--tests/expectations/tests/union_template.rs6
-rw-r--r--tests/expectations/tests/union_with_anon_struct.rs6
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield.rs6
-rw-r--r--tests/expectations/tests/union_with_anon_union.rs6
-rw-r--r--tests/expectations/tests/union_with_anon_unnamed_struct.rs6
-rw-r--r--tests/expectations/tests/union_with_anon_unnamed_union.rs6
-rw-r--r--tests/expectations/tests/union_with_big_member.rs21
-rw-r--r--tests/expectations/tests/union_with_nesting.rs6
-rw-r--r--tests/headers/union_with_big_member.h5
20 files changed, 124 insertions, 19 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index a0b26ead..3f7c87e8 100755
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1930,8 +1930,10 @@ mod utils {
pub fn prepend_union_types(ctx: &BindgenContext,
result: &mut Vec<P<ast::Item>>) {
let prefix = ctx.trait_prefix();
+
+ // TODO(emilio): The fmt::Debug impl could be way nicer with
+ // std::intrinsics::type_name, but...
let union_field_decl = quote_item!(ctx.ext_cx(),
- #[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(
::$prefix::marker::PhantomData<T>);
@@ -1983,11 +1985,22 @@ mod utils {
)
.unwrap();
+ let union_field_debug_impl = quote_item!(ctx.ext_cx(),
+ impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter)
+ -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+ }
+ )
+ .unwrap();
+
let items = vec![
union_field_decl, union_field_impl,
union_field_default_impl,
union_field_clone_impl,
union_field_copy_impl,
+ union_field_debug_impl,
];
let old_items = mem::replace(result, items);
diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs
index 0b1da364..8af416c3 100644
--- a/tests/expectations/tests/anon_union.rs
+++ b/tests/expectations/tests/anon_union.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TErrorResult<T> {
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index 4f736342..579c24a4 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
pub struct C {
pub a: ::std::os::raw::c_int,
diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs
index ca8eb73b..ab51396d 100644
--- a/tests/expectations/tests/class_with_inner_struct.rs
+++ b/tests/expectations/tests/class_with_inner_struct.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct A {
diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs
index fa611f20..91f898af 100644
--- a/tests/expectations/tests/jsval_layout_opaque.rs
+++ b/tests/expectations/tests/jsval_layout_opaque.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47;
pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327;
pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328;
diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs
index 7c4a7d82..0d2e937a 100644
--- a/tests/expectations/tests/struct_with_anon_union.rs
+++ b/tests/expectations/tests/struct_with_anon_union.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs
index 0763f590..2914eb41 100644
--- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs
+++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs
index 0aacb6b3..97a0949e 100644
--- a/tests/expectations/tests/struct_with_nesting.rs
+++ b/tests/expectations/tests/struct_with_nesting.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs
index a8fe14cd..da944146 100644
--- a/tests/expectations/tests/typeref.rs
+++ b/tests/expectations/tests/typeref.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct nsFoo {
diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs
index 4d1fa25a..9be626ff 100644
--- a/tests/expectations/tests/union_dtor.rs
+++ b/tests/expectations/tests/union_dtor.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug)]
pub struct UnionWithDtor {
diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs
index 49bdca13..495e80f9 100644
--- a/tests/expectations/tests/union_fields.rs
+++ b/tests/expectations/tests/union_fields.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct _bindgen_ty_1 {
diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs
index 0114e306..fc92afb8 100644
--- a/tests/expectations/tests/union_template.rs
+++ b/tests/expectations/tests/union_template.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NastyStruct<T> {
diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs
index 406dd231..f0a21512 100644
--- a/tests/expectations/tests/union_with_anon_struct.rs
+++ b/tests/expectations/tests/union_with_anon_struct.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
index 91d9fa59..548b0dc4 100644
--- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs
+++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs
index c7ca3411..95278556 100644
--- a/tests/expectations/tests/union_with_anon_union.rs
+++ b/tests/expectations/tests/union_with_anon_union.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs
index 33d75aff..2d6fab97 100644
--- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs
+++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct pixel {
diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs
index c47850f5..eb214017 100644
--- a/tests/expectations/tests/union_with_anon_unnamed_union.rs
+++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs
index 521a5ff4..b921f33c 100644
--- a/tests/expectations/tests/union_with_big_member.rs
+++ b/tests/expectations/tests/union_with_big_member.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Copy)]
pub struct WithBigArray {
@@ -40,6 +44,21 @@ impl Clone for WithBigArray {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct WithBigArray2 {
+ pub a: __BindgenUnionField<::std::os::raw::c_int>,
+ pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>,
+ pub bindgen_union_field: [u32; 9usize],
+}
+#[test]
+fn bindgen_test_layout_WithBigArray2() {
+ assert_eq!(::std::mem::size_of::<WithBigArray2>() , 36usize);
+ assert_eq!(::std::mem::align_of::<WithBigArray2>() , 4usize);
+}
+impl Clone for WithBigArray2 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
#[derive(Copy)]
pub struct WithBigMember {
pub a: __BindgenUnionField<::std::os::raw::c_int>,
diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs
index 6ed81adb..61c08a2a 100644
--- a/tests/expectations/tests/union_with_nesting.rs
+++ b/tests/expectations/tests/union_with_nesting.rs
@@ -4,7 +4,6 @@
#![allow(non_snake_case)]
-#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -24,6 +23,11 @@ impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
fn clone(&self) -> Self { Self::new() }
}
impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
diff --git a/tests/headers/union_with_big_member.h b/tests/headers/union_with_big_member.h
index 06682ef1..6347d6ca 100644
--- a/tests/headers/union_with_big_member.h
+++ b/tests/headers/union_with_big_member.h
@@ -3,6 +3,11 @@ union WithBigArray {
int b[33];
};
+union WithBigArray2 {
+ int a;
+ char b[33];
+};
+
union WithBigMember {
int a;
union WithBigArray b;