Skip to content

Commit dfe5185

Browse files
committed
Existing test adjustments.
1 parent bf9b3e9 commit dfe5185

11 files changed

+147
-147
lines changed

tests/expectations/tests/class_nested.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,6 @@ impl Clone for A_B {
3030
fn clone(&self) -> Self { *self }
3131
}
3232
#[repr(C)]
33-
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
34-
pub struct A_C {
35-
pub baz: ::std::os::raw::c_int,
36-
}
37-
#[test]
38-
fn bindgen_test_layout_A_C() {
39-
assert_eq!(::std::mem::size_of::<A_C>() , 4usize , concat ! (
40-
"Size of: " , stringify ! ( A_C ) ));
41-
assert_eq! (::std::mem::align_of::<A_C>() , 4usize , concat ! (
42-
"Alignment of " , stringify ! ( A_C ) ));
43-
assert_eq! (unsafe {
44-
& ( * ( 0 as * const A_C ) ) . baz as * const _ as usize } ,
45-
0usize , concat ! (
46-
"Alignment of field: " , stringify ! ( A_C ) , "::" ,
47-
stringify ! ( baz ) ));
48-
}
49-
impl Clone for A_C {
50-
fn clone(&self) -> Self { *self }
51-
}
52-
#[repr(C)]
5333
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
5434
pub struct A_D<T> {
5535
pub foo: T,
@@ -73,6 +53,26 @@ fn bindgen_test_layout_A() {
7353
impl Clone for A {
7454
fn clone(&self) -> Self { *self }
7555
}
56+
#[repr(C)]
57+
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
58+
pub struct C {
59+
pub baz: ::std::os::raw::c_int,
60+
}
61+
#[test]
62+
fn bindgen_test_layout_C() {
63+
assert_eq!(::std::mem::size_of::<C>() , 4usize , concat ! (
64+
"Size of: " , stringify ! ( C ) ));
65+
assert_eq! (::std::mem::align_of::<C>() , 4usize , concat ! (
66+
"Alignment of " , stringify ! ( C ) ));
67+
assert_eq! (unsafe {
68+
& ( * ( 0 as * const C ) ) . baz as * const _ as usize } ,
69+
0usize , concat ! (
70+
"Alignment of field: " , stringify ! ( C ) , "::" , stringify
71+
! ( baz ) ));
72+
}
73+
impl Clone for C {
74+
fn clone(&self) -> Self { *self }
75+
}
7676
extern "C" {
7777
#[link_name = "var"]
7878
pub static mut var: A_B;

tests/expectations/tests/forward-inherit-struct-with-fields.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
#[repr(C)]
88
#[derive(Debug, Copy, Clone)]
9-
pub struct Rooted<T> {
10-
pub _base: js_RootedBase<T>,
9+
pub struct js_RootedBase<T> {
10+
pub foo: *mut T,
11+
pub next: *mut Rooted<T>,
1112
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
1213
}
13-
impl <T> Default for Rooted<T> {
14+
impl <T> Default for js_RootedBase<T> {
1415
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
1516
}
1617
#[repr(C)]
1718
#[derive(Debug, Copy, Clone)]
18-
pub struct js_RootedBase<T> {
19-
pub foo: *mut T,
20-
pub next: *mut Rooted<T>,
19+
pub struct Rooted<T> {
20+
pub _base: js_RootedBase<T>,
2121
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
2222
}
23-
impl <T> Default for js_RootedBase<T> {
23+
impl <T> Default for Rooted<T> {
2424
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
2525
}

tests/expectations/tests/forward-inherit-struct.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
55

66

7+
#[repr(C)]
8+
#[derive(Debug, Default, Copy, Clone)]
9+
pub struct js_RootedBase {
10+
pub _address: u8,
11+
}
712
#[repr(C)]
813
#[derive(Debug, Copy, Clone)]
914
pub struct Rooted {
@@ -12,8 +17,3 @@ pub struct Rooted {
1217
impl Default for Rooted {
1318
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
1419
}
15-
#[repr(C)]
16-
#[derive(Debug, Default, Copy, Clone)]
17-
pub struct js_RootedBase {
18-
pub _address: u8,
19-
}

tests/expectations/tests/issue-372.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,6 @@ pub mod root {
1010
use self::super::root;
1111
#[repr(C)]
1212
#[derive(Debug, Copy)]
13-
pub struct d {
14-
pub m: root::i,
15-
}
16-
#[test]
17-
fn bindgen_test_layout_d() {
18-
assert_eq!(::std::mem::size_of::<d>() , 24usize , concat ! (
19-
"Size of: " , stringify ! ( d ) ));
20-
assert_eq! (::std::mem::align_of::<d>() , 8usize , concat ! (
21-
"Alignment of " , stringify ! ( d ) ));
22-
assert_eq! (unsafe {
23-
& ( * ( 0 as * const d ) ) . m as * const _ as usize } ,
24-
0usize , concat ! (
25-
"Alignment of field: " , stringify ! ( d ) , "::" ,
26-
stringify ! ( m ) ));
27-
}
28-
impl Clone for d {
29-
fn clone(&self) -> Self { *self }
30-
}
31-
impl Default for d {
32-
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
33-
}
34-
#[repr(C)]
35-
#[derive(Debug, Copy)]
3613
pub struct i {
3714
pub j: *mut root::i,
3815
pub k: *mut root::i,
@@ -66,6 +43,29 @@ pub mod root {
6643
impl Default for i {
6744
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
6845
}
46+
#[repr(C)]
47+
#[derive(Debug, Copy)]
48+
pub struct d {
49+
pub m: root::i,
50+
}
51+
#[test]
52+
fn bindgen_test_layout_d() {
53+
assert_eq!(::std::mem::size_of::<d>() , 24usize , concat ! (
54+
"Size of: " , stringify ! ( d ) ));
55+
assert_eq! (::std::mem::align_of::<d>() , 8usize , concat ! (
56+
"Alignment of " , stringify ! ( d ) ));
57+
assert_eq! (unsafe {
58+
& ( * ( 0 as * const d ) ) . m as * const _ as usize } ,
59+
0usize , concat ! (
60+
"Alignment of field: " , stringify ! ( d ) , "::" ,
61+
stringify ! ( m ) ));
62+
}
63+
impl Clone for d {
64+
fn clone(&self) -> Self { *self }
65+
}
66+
impl Default for d {
67+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
68+
}
6969
#[repr(u32)]
7070
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
7171
pub enum n {

tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,6 @@
55

66
pub type RefPtr<T> = T;
77

8-
#[repr(C)]
9-
#[derive(Debug, Copy)]
10-
pub struct b {
11-
pub _base: g,
12-
}
13-
#[test]
14-
fn bindgen_test_layout_b() {
15-
assert_eq!(::std::mem::size_of::<b>() , 1usize , concat ! (
16-
"Size of: " , stringify ! ( b ) ));
17-
assert_eq! (::std::mem::align_of::<b>() , 1usize , concat ! (
18-
"Alignment of " , stringify ! ( b ) ));
19-
}
20-
impl Clone for b {
21-
fn clone(&self) -> Self { *self }
22-
}
23-
impl Default for b {
24-
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
25-
}
268
#[repr(C)]
279
#[derive(Debug, Default, Copy)]
2810
pub struct A {
@@ -75,6 +57,24 @@ impl Clone for g {
7557
impl Default for g {
7658
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
7759
}
60+
#[repr(C)]
61+
#[derive(Debug, Copy)]
62+
pub struct b {
63+
pub _base: g,
64+
}
65+
#[test]
66+
fn bindgen_test_layout_b() {
67+
assert_eq!(::std::mem::size_of::<b>() , 1usize , concat ! (
68+
"Size of: " , stringify ! ( b ) ));
69+
assert_eq! (::std::mem::align_of::<b>() , 1usize , concat ! (
70+
"Alignment of " , stringify ! ( b ) ));
71+
}
72+
impl Clone for b {
73+
fn clone(&self) -> Self { *self }
74+
}
75+
impl Default for b {
76+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
77+
}
7878
extern "C" {
7979
#[link_name = "_Z25Servo_Element_GetSnapshotv"]
8080
pub fn Servo_Element_GetSnapshot() -> A;

tests/expectations/tests/objc_class.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
extern crate objc;
1010
#[allow(non_camel_case_types)]
1111
pub type id = *mut objc::runtime::Object;
12+
extern "C" {
13+
#[link_name = "fooVar"]
14+
pub static mut fooVar: *mut id;
15+
}
1216
pub trait Foo {
1317
unsafe fn method(self);
1418
}
1519
impl Foo for id {
1620
unsafe fn method(self) { msg_send!(self , method) }
1721
}
18-
extern "C" {
19-
#[link_name = "fooVar"]
20-
pub static mut fooVar: *mut id;
21-
}

tests/expectations/tests/opaque-tracing.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
55

66

7+
extern "C" {
8+
#[link_name = "_Z3fooP9Container"]
9+
pub fn foo(c: *mut Container);
10+
}
711
#[repr(C)]
812
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
913
pub struct Container {
@@ -19,7 +23,3 @@ fn bindgen_test_layout_Container() {
1923
impl Clone for Container {
2024
fn clone(&self) -> Self { *self }
2125
}
22-
extern "C" {
23-
#[link_name = "_Z3fooP9Container"]
24-
pub fn foo(c: *mut Container);
25-
}

tests/expectations/tests/template.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl Clone for RootedContainer {
192192
impl Default for RootedContainer {
193193
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
194194
}
195+
pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>;
195196
#[repr(C)]
196197
#[derive(Debug, Hash, PartialEq, Eq)]
197198
pub struct WithDtor<T> {
@@ -201,7 +202,6 @@ pub struct WithDtor<T> {
201202
impl <T> Default for WithDtor<T> {
202203
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
203204
}
204-
pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>;
205205
#[repr(C)]
206206
#[derive(Debug, Hash, PartialEq, Eq)]
207207
pub struct PODButContainsDtor {
@@ -268,22 +268,22 @@ impl <T> Default for NestedBase<T> {
268268
}
269269
#[repr(C)]
270270
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
271-
pub struct Incomplete<T> {
272-
pub d: T,
271+
pub struct NestedContainer<T> {
272+
pub c: T,
273+
pub nested: NestedReplaced<T>,
274+
pub inc: Incomplete<T>,
273275
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
274276
}
275-
impl <T> Default for Incomplete<T> {
277+
impl <T> Default for NestedContainer<T> {
276278
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
277279
}
278280
#[repr(C)]
279281
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
280-
pub struct NestedContainer<T> {
281-
pub c: T,
282-
pub nested: NestedReplaced<T>,
283-
pub inc: Incomplete<T>,
282+
pub struct Incomplete<T> {
283+
pub d: T,
284284
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
285285
}
286-
impl <T> Default for NestedContainer<T> {
286+
impl <T> Default for Incomplete<T> {
287287
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
288288
}
289289
#[repr(C)]

tests/expectations/tests/typeref.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@
44
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
55

66

7-
#[repr(C)]
8-
pub struct nsFoo {
9-
pub mBar: mozilla_StyleShapeSource,
10-
}
11-
#[test]
12-
fn bindgen_test_layout_nsFoo() {
13-
assert_eq!(::std::mem::size_of::<nsFoo>() , 8usize , concat ! (
14-
"Size of: " , stringify ! ( nsFoo ) ));
15-
assert_eq! (::std::mem::align_of::<nsFoo>() , 8usize , concat ! (
16-
"Alignment of " , stringify ! ( nsFoo ) ));
17-
assert_eq! (unsafe {
18-
& ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize }
19-
, 0usize , concat ! (
20-
"Alignment of field: " , stringify ! ( nsFoo ) , "::" ,
21-
stringify ! ( mBar ) ));
22-
}
23-
impl Default for nsFoo {
24-
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
25-
}
267
#[repr(C)]
278
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
289
pub struct mozilla_FragmentOrURL {
@@ -99,6 +80,25 @@ impl Clone for Bar {
9980
impl Default for Bar {
10081
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
10182
}
83+
#[repr(C)]
84+
pub struct nsFoo {
85+
pub mBar: mozilla_StyleShapeSource,
86+
}
87+
#[test]
88+
fn bindgen_test_layout_nsFoo() {
89+
assert_eq!(::std::mem::size_of::<nsFoo>() , 8usize , concat ! (
90+
"Size of: " , stringify ! ( nsFoo ) ));
91+
assert_eq! (::std::mem::align_of::<nsFoo>() , 8usize , concat ! (
92+
"Alignment of " , stringify ! ( nsFoo ) ));
93+
assert_eq! (unsafe {
94+
& ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize }
95+
, 0usize , concat ! (
96+
"Alignment of field: " , stringify ! ( nsFoo ) , "::" ,
97+
stringify ! ( mBar ) ));
98+
}
99+
impl Default for nsFoo {
100+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
101+
}
102102
#[test]
103103
fn __bindgen_test_layout_mozilla_StyleShapeSource_open0_int_close0_instantiation() {
104104
assert_eq!(::std::mem::size_of::<mozilla_StyleShapeSource>() , 8usize ,

0 commit comments

Comments
 (0)