@@ -5,6 +5,7 @@ fn with_anon_struct() {
5
5
assert_bind_eq ( Default :: default ( ) , "headers/union_with_anon_struct.h" , "
6
6
#[repr(C)]
7
7
#[derive(Copy)]
8
+ #[derive(Debug)]
8
9
pub struct Union_foo {
9
10
pub _bindgen_data_: [u32; 2usize],
10
11
}
@@ -41,6 +42,7 @@ fn with_anon_struct_bitfield() {
41
42
assert_bind_eq ( Default :: default ( ) , "headers/union_with_anon_struct_bitfield.h" , "
42
43
#[repr(C)]
43
44
#[derive(Copy)]
45
+ #[derive(Debug)]
44
46
pub struct Union_foo {
45
47
pub _bindgen_data_: [u32; 1usize],
46
48
}
@@ -67,6 +69,7 @@ fn with_anon_union() {
67
69
assert_bind_eq ( Default :: default ( ) , "headers/union_with_anon_union.h" , "
68
70
#[repr(C)]
69
71
#[derive(Copy)]
72
+ #[derive(Debug)]
70
73
pub struct Union_foo {
71
74
pub _bindgen_data_: [u32; 1usize],
72
75
}
@@ -84,6 +87,7 @@ fn with_anon_union() {
84
87
}
85
88
#[repr(C)]
86
89
#[derive(Copy)]
90
+ #[derive(Debug)]
87
91
pub struct Union_Unnamed1 {
88
92
pub _bindgen_data_: [u32; 1usize],
89
93
}
@@ -111,6 +115,7 @@ fn with_anon_unnamed_struct() {
111
115
assert_bind_eq ( Default :: default ( ) , "headers/union_with_anon_unnamed_struct.h" , "
112
116
#[repr(C)]
113
117
#[derive(Copy)]
118
+ #[derive(Debug)]
114
119
pub struct Union_pixel {
115
120
pub _bindgen_data_: [u32; 1usize],
116
121
}
@@ -150,6 +155,7 @@ fn with_anon_unnamed_union() {
150
155
assert_bind_eq ( Default :: default ( ) , "headers/union_with_anon_unnamed_union.h" , "
151
156
#[repr(C)]
152
157
#[derive(Copy)]
158
+ #[derive(Debug)]
153
159
pub struct Union_foo {
154
160
pub _bindgen_data_: [u32; 1usize],
155
161
}
@@ -181,6 +187,7 @@ fn with_nesting() {
181
187
assert_bind_eq ( Default :: default ( ) , "headers/union_with_nesting.h" , "
182
188
#[repr(C)]
183
189
#[derive(Copy)]
190
+ #[derive(Debug)]
184
191
pub struct Union_foo {
185
192
pub _bindgen_data_: [u32; 1usize],
186
193
}
@@ -214,3 +221,51 @@ fn with_nesting() {
214
221
}
215
222
" ) ;
216
223
}
224
+
225
+ #[ test]
226
+ fn with_derive_debug ( ) {
227
+ assert_bind_eq ( Default :: default ( ) , "headers/union_with_big_member.h" , "
228
+ #[repr(C)]
229
+ #[derive(Copy)]
230
+ pub struct Union_WithBigArray {
231
+ pub _bindgen_data_: [u32; 33usize],
232
+ }
233
+ impl Union_WithBigArray {
234
+ pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
235
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
236
+ ::std::mem::transmute(raw.offset(0))
237
+ }
238
+ pub unsafe fn b(&mut self) -> *mut [::std::os::raw::c_int; 33usize] {
239
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
240
+ ::std::mem::transmute(raw.offset(0))
241
+ }
242
+ }
243
+ impl ::std::clone::Clone for Union_WithBigArray {
244
+ fn clone(&self) -> Self { *self }
245
+ }
246
+ impl ::std::default::Default for Union_WithBigArray {
247
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
248
+ }
249
+ #[repr(C)]
250
+ #[derive(Copy)]
251
+ pub struct Union_WithBigMember {
252
+ pub _bindgen_data_: [u32; 33usize],
253
+ }
254
+ impl Union_WithBigMember {
255
+ pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
256
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
257
+ ::std::mem::transmute(raw.offset(0))
258
+ }
259
+ pub unsafe fn b(&mut self) -> *mut Union_WithBigArray {
260
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
261
+ ::std::mem::transmute(raw.offset(0))
262
+ }
263
+ }
264
+ impl ::std::clone::Clone for Union_WithBigMember {
265
+ fn clone(&self) -> Self { *self }
266
+ }
267
+ impl ::std::default::Default for Union_WithBigMember {
268
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
269
+ }
270
+ " ) ;
271
+ }
0 commit comments