/
comment-indent.rs
136 lines (135 loc) · 4.11 KB
/
comment-indent.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
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
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::super::root;
/// This is a multi-line doc comment.
///
/// This class is really really interesting, look!
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
/// This nested class is also a multi-line doc comment.
///
/// This class is not so interesting, but worth a bit of docs too!
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo_Bar {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_Foo_Bar() {
assert_eq!(
::std::mem::size_of::<Foo_Bar>(),
1usize,
concat!("Size of: ", stringify!(Foo_Bar))
);
assert_eq!(
::std::mem::align_of::<Foo_Bar>(),
1usize,
concat!("Alignment of ", stringify!(Foo_Bar))
);
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
::std::mem::size_of::<Foo>(),
1usize,
concat!("Size of: ", stringify!(Foo))
);
assert_eq!(
::std::mem::align_of::<Foo>(),
1usize,
concat!("Alignment of ", stringify!(Foo))
);
}
pub mod test {
#[allow(unused_imports)]
use self::super::super::root;
/// I'm in a namespace, and thus I may be on a rust module, most of the time.
/// My documentation is pretty extensive, I guess.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Baz {
/// This member is plain awesome, just amazing.
///
/// It also has super-extensive docs, with even a nice ascii-art diagram.
///
/// +------+ +-------+
/// | foo | ----> | bar |
/// +------+ +-------+
pub member: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_Baz() {
assert_eq!(
::std::mem::size_of::<Baz>(),
4usize,
concat!("Size of: ", stringify!(Baz))
);
assert_eq!(
::std::mem::align_of::<Baz>(),
4usize,
concat!("Alignment of ", stringify!(Baz))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<Baz>())).member as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(Baz),
"::",
stringify!(member)
)
);
}
/// I'm in an inline namespace, and as such I shouldn't get generated inside
/// a rust module, except when the relevant option is specified. Also, this
/// comment shouldn't be misaligned.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct InInlineNS {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_InInlineNS() {
assert_eq!(
::std::mem::size_of::<InInlineNS>(),
1usize,
concat!("Size of: ", stringify!(InInlineNS))
);
assert_eq!(
::std::mem::align_of::<InInlineNS>(),
1usize,
concat!("Alignment of ", stringify!(InInlineNS))
);
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bazz {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_Bazz() {
assert_eq!(
::std::mem::size_of::<Bazz>(),
1usize,
concat!("Size of: ", stringify!(Bazz))
);
assert_eq!(
::std::mem::align_of::<Bazz>(),
1usize,
concat!("Alignment of ", stringify!(Bazz))
);
}
}
}