summaryrefslogtreecommitdiff
path: root/tests/expectations/tests/class_nested.rs
blob: 55ea6e1defa8e6ccf8f53594f6094c651a477ce6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#![allow(
    dead_code,
    non_snake_case,
    non_camel_case_types,
    non_upper_case_globals
)]

#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A {
    pub member_a: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_B {
    pub member_b: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_A_B() {
    assert_eq!(
        ::std::mem::size_of::<A_B>(),
        4usize,
        concat!("Size of: ", stringify!(A_B))
    );
    assert_eq!(
        ::std::mem::align_of::<A_B>(),
        4usize,
        concat!("Alignment of ", stringify!(A_B))
    );
    assert_eq!(
        unsafe {
            let uninit = ::std::mem::MaybeUninit::<A_B>::uninit();
            let ptr = uninit.as_ptr();
            ::std::ptr::addr_of!((*ptr).member_b) as usize - ptr as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(A_B),
            "::",
            stringify!(member_b)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_D<T> {
    pub foo: T,
    pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for A_D<T> {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
#[test]
fn bindgen_test_layout_A() {
    assert_eq!(
        ::std::mem::size_of::<A>(),
        4usize,
        concat!("Size of: ", stringify!(A))
    );
    assert_eq!(
        ::std::mem::align_of::<A>(),
        4usize,
        concat!("Alignment of ", stringify!(A))
    );
    assert_eq!(
        unsafe {
            let uninit = ::std::mem::MaybeUninit::<A>::uninit();
            let ptr = uninit.as_ptr();
            ::std::ptr::addr_of!((*ptr).member_a) as usize - ptr as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(A),
            "::",
            stringify!(member_a)
        )
    );
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_C {
    pub baz: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_A_C() {
    assert_eq!(
        ::std::mem::size_of::<A_C>(),
        4usize,
        concat!("Size of: ", stringify!(A_C))
    );
    assert_eq!(
        ::std::mem::align_of::<A_C>(),
        4usize,
        concat!("Alignment of ", stringify!(A_C))
    );
    assert_eq!(
        unsafe {
            let uninit = ::std::mem::MaybeUninit::<A_C>::uninit();
            let ptr = uninit.as_ptr();
            ::std::ptr::addr_of!((*ptr).baz) as usize - ptr as usize
        },
        0usize,
        concat!("Offset of field: ", stringify!(A_C), "::", stringify!(baz))
    );
}
extern "C" {
    pub static mut var: A_B;
}
#[test]
fn __bindgen_test_layout_A_D_open0_int_close0_instantiation() {
    assert_eq!(
        ::std::mem::size_of::<A_D<::std::os::raw::c_int>>(),
        4usize,
        concat!(
            "Size of template specialization: ",
            stringify!(A_D<::std::os::raw::c_int>)
        )
    );
    assert_eq!(
        ::std::mem::align_of::<A_D<::std::os::raw::c_int>>(),
        4usize,
        concat!(
            "Alignment of template specialization: ",
            stringify!(A_D<::std::os::raw::c_int>)
        )
    );
}
extern "C" {
    pub static mut baz: A_D<::std::os::raw::c_int>;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct D {
    pub member: A_B,
}
#[test]
fn bindgen_test_layout_D() {
    assert_eq!(
        ::std::mem::size_of::<D>(),
        4usize,
        concat!("Size of: ", stringify!(D))
    );
    assert_eq!(
        ::std::mem::align_of::<D>(),
        4usize,
        concat!("Alignment of ", stringify!(D))
    );
    assert_eq!(
        unsafe {
            let uninit = ::std::mem::MaybeUninit::<D>::uninit();
            let ptr = uninit.as_ptr();
            ::std::ptr::addr_of!((*ptr).member) as usize - ptr as usize
        },
        0usize,
        concat!("Offset of field: ", stringify!(D), "::", stringify!(member))
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Templated<T> {
    pub member: T,
    pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Templated_Templated_inner<T> {
    pub member_ptr: *mut T,
    pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for Templated_Templated_inner<T> {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
impl<T> Default for Templated<T> {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}