1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 #[repr(C)]
9 #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)]
10 pub struct Blocklisted<T> {
11     t: T,
12     pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
13 }
14 
15 /// This would derive(Hash, Eq, PartialEq) if it didn't contain a blocklisted type,
16 /// causing us to conservatively avoid deriving hash/Eq/PartialEq for it.
17 #[repr(C)]
18 pub struct AllowlistedOne {
19     pub a: Blocklisted<::std::os::raw::c_int>,
20 }
21 #[test]
bindgen_test_layout_AllowlistedOnenull22 fn bindgen_test_layout_AllowlistedOne() {
23     const UNINIT: ::std::mem::MaybeUninit<AllowlistedOne> =
24         ::std::mem::MaybeUninit::uninit();
25     let ptr = UNINIT.as_ptr();
26     assert_eq!(
27         ::std::mem::size_of::<AllowlistedOne>(),
28         4usize,
29         concat!("Size of: ", stringify!(AllowlistedOne))
30     );
31     assert_eq!(
32         ::std::mem::align_of::<AllowlistedOne>(),
33         4usize,
34         concat!("Alignment of ", stringify!(AllowlistedOne))
35     );
36     assert_eq!(
37         unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize },
38         0usize,
39         concat!(
40             "Offset of field: ",
41             stringify!(AllowlistedOne),
42             "::",
43             stringify!(a)
44         )
45     );
46 }
47 impl Default for AllowlistedOne {
defaultnull48     fn default() -> Self {
49         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
50         unsafe {
51             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
52             s.assume_init()
53         }
54     }
55 }
56 /// This can't derive(Hash/Eq) even if it didn't contain a blocklisted type.
57 #[repr(C)]
58 pub struct AllowlistedTwo {
59     pub b: Blocklisted<f32>,
60 }
61 #[test]
bindgen_test_layout_AllowlistedTwonull62 fn bindgen_test_layout_AllowlistedTwo() {
63     const UNINIT: ::std::mem::MaybeUninit<AllowlistedTwo> =
64         ::std::mem::MaybeUninit::uninit();
65     let ptr = UNINIT.as_ptr();
66     assert_eq!(
67         ::std::mem::size_of::<AllowlistedTwo>(),
68         4usize,
69         concat!("Size of: ", stringify!(AllowlistedTwo))
70     );
71     assert_eq!(
72         ::std::mem::align_of::<AllowlistedTwo>(),
73         4usize,
74         concat!("Alignment of ", stringify!(AllowlistedTwo))
75     );
76     assert_eq!(
77         unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize },
78         0usize,
79         concat!(
80             "Offset of field: ",
81             stringify!(AllowlistedTwo),
82             "::",
83             stringify!(b)
84         )
85     );
86 }
87 impl Default for AllowlistedTwo {
defaultnull88     fn default() -> Self {
89         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
90         unsafe {
91             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
92             s.assume_init()
93         }
94     }
95 }
96