/
class_with_dtor.rs
74 lines (73 loc) · 1.88 KB
/
class_with_dtor.rs
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
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct HandleWithDtor<T> {
pub ptr: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for HandleWithDtor<T> {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>;
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct WithoutDtor {
pub shouldBeWithDtor: HandleValue,
}
#[test]
fn bindgen_test_layout_WithoutDtor() {
assert_eq!(
::std::mem::size_of::<WithoutDtor>(),
8usize,
concat!("Size of: ", stringify!(WithoutDtor))
);
assert_eq!(
::std::mem::align_of::<WithoutDtor>(),
8usize,
concat!("Alignment of ", stringify!(WithoutDtor))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<WithoutDtor>())).shouldBeWithDtor as *const _
as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(WithoutDtor),
"::",
stringify!(shouldBeWithDtor)
)
);
}
impl Default for WithoutDtor {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[test]
fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
assert_eq!(
::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>(),
8usize,
concat!(
"Size of template specialization: ",
stringify!(HandleWithDtor<::std::os::raw::c_int>)
)
);
assert_eq!(
::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>(),
8usize,
concat!(
"Alignment of template specialization: ",
stringify!(HandleWithDtor<::std::os::raw::c_int>)
)
);
}