diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-02-08 06:49:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 06:49:51 -0800 |
commit | ddfa1e049917ad1caed834ebaf9fcfd1636dbfb9 (patch) | |
tree | def5ca75fc7880c77d51b1009c81ddb686bae3d4 /tests | |
parent | 8264afa875d686688680123859f8820e19c8028c (diff) | |
parent | 60361505fbce24fb564edc56e1b9bb7299932457 (diff) |
Auto merge of #489 - emilio:use-core, r=fitzgen
codegen: Fix remaining cases of missing core prefix.
Fixes #488
r? @fitzgen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/use-core.rs | 55 | ||||
-rw-r--r-- | tests/headers/use-core.h | 5 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index dd13156f..c2996f74 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -6,6 +6,30 @@ extern crate core; #[repr(C)] +pub struct __BindgenUnionField<T>(::core::marker::PhantomData<T>); +impl <T> __BindgenUnionField<T> { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::core::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::core::mem::transmute(self) } +} +impl <T> ::core::default::Default for __BindgenUnionField<T> { + #[inline] + fn default() -> Self { Self::new() } +} +impl <T> ::core::clone::Clone for __BindgenUnionField<T> { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl <T> ::core::marker::Copy for __BindgenUnionField<T> { } +impl <T> ::core::fmt::Debug for __BindgenUnionField<T> { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +#[repr(C)] #[derive(Debug, Copy)] pub struct foo { pub a: ::std::os::raw::c_int, @@ -40,5 +64,36 @@ impl Clone for foo { impl Default for foo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct _bindgen_ty_1 { + pub bar: __BindgenUnionField<::std::os::raw::c_int>, + pub baz: __BindgenUnionField<::std::os::raw::c_long>, + pub bindgen_union_field: u64, +} +#[test] +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::core::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( + "Size of: " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (::core::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( + "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" + , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" + , stringify ! ( baz ) )); +} +impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +extern "C" { + #[link_name = "bazz"] + pub static mut bazz: _bindgen_ty_1; +} pub type fooFunction = ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>; diff --git a/tests/headers/use-core.h b/tests/headers/use-core.h index 42bb10d9..0e8a8d6e 100644 --- a/tests/headers/use-core.h +++ b/tests/headers/use-core.h @@ -5,4 +5,9 @@ struct foo { void* bar; }; +union { + int bar; + long baz; +} bazz; + typedef void (*fooFunction)(int bar); |