1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 /// We emit a `[u8; 63usize]` padding field for this struct, which cannot derive
9 /// Debug/Hash because 63 is over the hard coded limit.
10 #[repr(C)]
11 #[repr(align(64))]
12 #[derive(Copy, Clone)]
13 pub struct NoDebug {
14     pub c: ::std::os::raw::c_char,
15 }
16 #[test]
bindgen_test_layout_NoDebugnull17 fn bindgen_test_layout_NoDebug() {
18     const UNINIT: ::std::mem::MaybeUninit<NoDebug> =
19         ::std::mem::MaybeUninit::uninit();
20     let ptr = UNINIT.as_ptr();
21     assert_eq!(
22         ::std::mem::size_of::<NoDebug>(),
23         64usize,
24         concat!("Size of: ", stringify!(NoDebug))
25     );
26     assert_eq!(
27         ::std::mem::align_of::<NoDebug>(),
28         64usize,
29         concat!("Alignment of ", stringify!(NoDebug))
30     );
31     assert_eq!(
32         unsafe { ::std::ptr::addr_of!((*ptr).c) as usize - ptr as usize },
33         0usize,
34         concat!(
35             "Offset of field: ",
36             stringify!(NoDebug),
37             "::",
38             stringify!(c)
39         )
40     );
41 }
42 impl Default for NoDebug {
defaultnull43     fn default() -> Self {
44         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
45         unsafe {
46             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
47             s.assume_init()
48         }
49     }
50 }
51 impl ::std::cmp::PartialEq for NoDebug {
eqnull52     fn eq(&self, other: &NoDebug) -> bool {
53         self.c == other.c
54     }
55 }
56 /// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive
57 /// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because
58 /// we determine Debug derive-ability before we compute padding, which happens at
59 /// codegen.
60 #[repr(C)]
61 #[repr(align(64))]
62 #[derive(Copy, Clone)]
63 pub struct ShouldDeriveDebugButDoesNot {
64     pub c: [::std::os::raw::c_char; 32usize],
65     pub d: ::std::os::raw::c_char,
66 }
67 #[test]
bindgen_test_layout_ShouldDeriveDebugButDoesNotnull68 fn bindgen_test_layout_ShouldDeriveDebugButDoesNot() {
69     const UNINIT: ::std::mem::MaybeUninit<ShouldDeriveDebugButDoesNot> =
70         ::std::mem::MaybeUninit::uninit();
71     let ptr = UNINIT.as_ptr();
72     assert_eq!(
73         ::std::mem::size_of::<ShouldDeriveDebugButDoesNot>(),
74         64usize,
75         concat!("Size of: ", stringify!(ShouldDeriveDebugButDoesNot))
76     );
77     assert_eq!(
78         ::std::mem::align_of::<ShouldDeriveDebugButDoesNot>(),
79         64usize,
80         concat!("Alignment of ", stringify!(ShouldDeriveDebugButDoesNot))
81     );
82     assert_eq!(
83         unsafe { ::std::ptr::addr_of!((*ptr).c) as usize - ptr as usize },
84         0usize,
85         concat!(
86             "Offset of field: ",
87             stringify!(ShouldDeriveDebugButDoesNot),
88             "::",
89             stringify!(c)
90         )
91     );
92     assert_eq!(
93         unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize },
94         32usize,
95         concat!(
96             "Offset of field: ",
97             stringify!(ShouldDeriveDebugButDoesNot),
98             "::",
99             stringify!(d)
100         )
101     );
102 }
103 impl Default for ShouldDeriveDebugButDoesNot {
defaultnull104     fn default() -> Self {
105         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
106         unsafe {
107             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
108             s.assume_init()
109         }
110     }
111 }
112 impl ::std::cmp::PartialEq for ShouldDeriveDebugButDoesNot {
eqnull113     fn eq(&self, other: &ShouldDeriveDebugButDoesNot) -> bool {
114         self.c == other.c && self.d == other.d
115     }
116 }
117