1 #![allow(
2 dead_code,
3 non_snake_case,
4 non_camel_case_types,
5 non_upper_case_globals
6 )]
7
8 pub struct BlocklistMe(u8);
9
10 /// Because this type contains a blocklisted type, it should not derive
11 /// Default. Instead, we should emit a `mem::zeroed` implementation.
12 #[repr(C)]
13 pub struct ShouldNotDeriveDefault {
14 pub a: BlocklistMe,
15 }
16 #[test]
bindgen_test_layout_ShouldNotDeriveDefaultnull17 fn bindgen_test_layout_ShouldNotDeriveDefault() {
18 const UNINIT: ::std::mem::MaybeUninit<ShouldNotDeriveDefault> =
19 ::std::mem::MaybeUninit::uninit();
20 let ptr = UNINIT.as_ptr();
21 assert_eq!(
22 ::std::mem::size_of::<ShouldNotDeriveDefault>(),
23 1usize,
24 concat!("Size of: ", stringify!(ShouldNotDeriveDefault))
25 );
26 assert_eq!(
27 ::std::mem::align_of::<ShouldNotDeriveDefault>(),
28 1usize,
29 concat!("Alignment of ", stringify!(ShouldNotDeriveDefault))
30 );
31 assert_eq!(
32 unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize },
33 0usize,
34 concat!(
35 "Offset of field: ",
36 stringify!(ShouldNotDeriveDefault),
37 "::",
38 stringify!(a)
39 )
40 );
41 }
42 impl Default for ShouldNotDeriveDefault {
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