diff --git a/bindgen-tests/tests/expectations/tests/allowlist-file.rs b/bindgen-tests/tests/expectations/tests/allowlist-file.rs index 1ee7a192ed..63953ccb67 100644 --- a/bindgen-tests/tests/expectations/tests/allowlist-file.rs +++ b/bindgen-tests/tests/expectations/tests/allowlist-file.rs @@ -1,5 +1,4 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub const SOME_DEFUN: u32 = 123; extern "C" { #[link_name = "\u{1}_Z12SomeFunctionv"] pub fn SomeFunction(); @@ -7,6 +6,7 @@ extern "C" { extern "C" { pub static mut someVar: ::std::os::raw::c_int; } +pub const SOME_DEFUN: u32 = 123; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct someClass { diff --git a/bindgen-tests/tests/expectations/tests/blocks-signature.rs b/bindgen-tests/tests/expectations/tests/blocks-signature.rs index 6a5b873b94..d2b82c5b96 100644 --- a/bindgen-tests/tests/expectations/tests/blocks-signature.rs +++ b/bindgen-tests/tests/expectations/tests/blocks-signature.rs @@ -5,8 +5,13 @@ extern "C" { #[link_name = "\u{1}_Z8atexit_bU13block_pointerFvvE"] pub fn atexit_b(arg1: _bindgen_ty_id_33); } +pub type _bindgen_ty_id_33 = *const ::block::Block<(), ()>; pub type dispatch_data_t = *mut ::std::os::raw::c_void; pub type dispatch_data_applier_t = _bindgen_ty_id_40; +pub type _bindgen_ty_id_40 = *const ::block::Block< + (dispatch_data_t, usize, *const ::std::os::raw::c_void, usize), + bool, +>; extern "C" { #[link_name = "\u{1}_Z19dispatch_data_applyPvU13block_pointerFbS_yPKvyE"] pub fn dispatch_data_apply( @@ -18,10 +23,12 @@ extern "C" { #[link_name = "\u{1}_Z3fooU13block_pointerFvyE"] pub fn foo(arg1: _bindgen_ty_id_50) -> bool; } +pub type _bindgen_ty_id_50 = *const ::block::Block<(usize,), ()>; extern "C" { #[link_name = "\u{1}_Z7foo_ptrPU13block_pointerFvyE"] pub fn foo_ptr(arg1: *mut _bindgen_ty_id_56) -> bool; } +pub type _bindgen_ty_id_56 = *const ::block::Block<(usize,), ()>; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct contains_block_pointers { @@ -60,13 +67,6 @@ impl Default for contains_block_pointers { } } } -pub type _bindgen_ty_id_33 = *const ::block::Block<(), ()>; -pub type _bindgen_ty_id_40 = *const ::block::Block< - (dispatch_data_t, usize, *const ::std::os::raw::c_void, usize), - bool, ->; -pub type _bindgen_ty_id_50 = *const ::block::Block<(usize,), ()>; -pub type _bindgen_ty_id_56 = *const ::block::Block<(usize,), ()>; pub type contains_block_pointers__bindgen_ty_id_61 = *const ::block::Block< (::std::os::raw::c_int,), (), diff --git a/bindgen-tests/tests/expectations/tests/canonical-types.rs b/bindgen-tests/tests/expectations/tests/canonical-types.rs index 61faef16b0..e1e83d0415 100644 --- a/bindgen-tests/tests/expectations/tests/canonical-types.rs +++ b/bindgen-tests/tests/expectations/tests/canonical-types.rs @@ -73,21 +73,27 @@ impl Default for ClassC_ClassCInnerCRTP { } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct ClassD { - pub _address: u8, +pub struct ClassAInner { + pub x: *mut ClassCInnerA, } #[test] -fn bindgen_test_layout_ClassD() { +fn bindgen_test_layout_ClassAInner() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of:: < ClassD > (), 1usize, concat!("Size of: ", - stringify!(ClassD)) + ::std::mem::size_of:: < ClassAInner > (), 8usize, concat!("Size of: ", + stringify!(ClassAInner)) ); assert_eq!( - ::std::mem::align_of:: < ClassD > (), 1usize, concat!("Alignment of ", - stringify!(ClassD)) + ::std::mem::align_of:: < ClassAInner > (), 8usize, concat!("Alignment of ", + stringify!(ClassAInner)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((* ptr).x) as usize - ptr as usize }, 0usize, + concat!("Offset of field: ", stringify!(ClassAInner), "::", stringify!(x)) ); } -impl Default for ClassD { +impl Default for ClassAInner { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -96,17 +102,6 @@ impl Default for ClassD { } } } -#[test] -fn __bindgen_test_layout_ClassB_open0_ClassD_ClassCInnerCRTP_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < ClassB > (), 1usize, - concat!("Size of template specialization: ", stringify!(ClassB)) - ); - assert_eq!( - ::std::mem::align_of:: < ClassB > (), 1usize, - concat!("Alignment of template specialization: ", stringify!(ClassB)) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ClassCInnerCRTP { @@ -145,27 +140,21 @@ fn __bindgen_test_layout_ClassB_open0_ClassCInnerCRTP_ClassAInner_close0_instant } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct ClassAInner { - pub x: *mut ClassCInnerA, +pub struct ClassD { + pub _address: u8, } #[test] -fn bindgen_test_layout_ClassAInner() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of:: < ClassAInner > (), 8usize, concat!("Size of: ", - stringify!(ClassAInner)) - ); +fn bindgen_test_layout_ClassD() { assert_eq!( - ::std::mem::align_of:: < ClassAInner > (), 8usize, concat!("Alignment of ", - stringify!(ClassAInner)) + ::std::mem::size_of:: < ClassD > (), 1usize, concat!("Size of: ", + stringify!(ClassD)) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((* ptr).x) as usize - ptr as usize }, 0usize, - concat!("Offset of field: ", stringify!(ClassAInner), "::", stringify!(x)) + ::std::mem::align_of:: < ClassD > (), 1usize, concat!("Alignment of ", + stringify!(ClassD)) ); } -impl Default for ClassAInner { +impl Default for ClassD { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -174,6 +163,17 @@ impl Default for ClassAInner { } } } +#[test] +fn __bindgen_test_layout_ClassB_open0_ClassD_ClassCInnerCRTP_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < ClassB > (), 1usize, + concat!("Size of template specialization: ", stringify!(ClassB)) + ); + assert_eq!( + ::std::mem::align_of:: < ClassB > (), 1usize, + concat!("Alignment of template specialization: ", stringify!(ClassB)) + ); +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ClassCInnerA { diff --git a/bindgen-tests/tests/expectations/tests/class_nested.rs b/bindgen-tests/tests/expectations/tests/class_nested.rs index 66700efc09..f193a57fa2 100644 --- a/bindgen-tests/tests/expectations/tests/class_nested.rs +++ b/bindgen-tests/tests/expectations/tests/class_nested.rs @@ -1,5 +1,20 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Templated_Templated_inner { + pub member_ptr: *mut T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} +impl Default for Templated_Templated_inner { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct A { pub member_a: ::std::os::raw::c_int, @@ -121,21 +136,6 @@ pub struct Templated { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -#[repr(C)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Templated_Templated_inner { - pub member_ptr: *mut T, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, -} -impl Default for Templated_Templated_inner { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} impl Default for Templated { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); diff --git a/bindgen-tests/tests/expectations/tests/class_with_dtor.rs b/bindgen-tests/tests/expectations/tests/class_with_dtor.rs index 4060cf5398..5a29077ba1 100644 --- a/bindgen-tests/tests/expectations/tests/class_with_dtor.rs +++ b/bindgen-tests/tests/expectations/tests/class_with_dtor.rs @@ -15,6 +15,19 @@ impl Default for HandleWithDtor { } } pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>; +#[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 >)) + ); +} #[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct WithoutDtor { @@ -47,16 +60,3 @@ impl Default for WithoutDtor { } } } -#[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 >)) - ); -} diff --git a/bindgen-tests/tests/expectations/tests/crtp.rs b/bindgen-tests/tests/expectations/tests/crtp.rs index 08931f8893..3116488c83 100644 --- a/bindgen-tests/tests/expectations/tests/crtp.rs +++ b/bindgen-tests/tests/expectations/tests/crtp.rs @@ -20,6 +20,17 @@ fn bindgen_test_layout_Derived() { stringify!(Derived)) ); } +#[test] +fn __bindgen_test_layout_Base_open0_Derived_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < Base > (), 1usize, + concat!("Size of template specialization: ", stringify!(Base)) + ); + assert_eq!( + ::std::mem::align_of:: < Base > (), 1usize, + concat!("Alignment of template specialization: ", stringify!(Base)) + ); +} #[repr(C)] #[derive(Debug, Default)] pub struct BaseWithDestructor { @@ -42,17 +53,6 @@ fn bindgen_test_layout_DerivedFromBaseWithDestructor() { ); } #[test] -fn __bindgen_test_layout_Base_open0_Derived_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < Base > (), 1usize, - concat!("Size of template specialization: ", stringify!(Base)) - ); - assert_eq!( - ::std::mem::align_of:: < Base > (), 1usize, - concat!("Alignment of template specialization: ", stringify!(Base)) - ); -} -#[test] fn __bindgen_test_layout_BaseWithDestructor_open0_DerivedFromBaseWithDestructor_close0_instantiation() { assert_eq!( ::std::mem::size_of:: < BaseWithDestructor > (), 1usize, diff --git a/bindgen-tests/tests/expectations/tests/derive-hash-template-inst-float.rs b/bindgen-tests/tests/expectations/tests/derive-hash-template-inst-float.rs index cdece306e0..5cc6d7dc92 100644 --- a/bindgen-tests/tests/expectations/tests/derive-hash-template-inst-float.rs +++ b/bindgen-tests/tests/expectations/tests/derive-hash-template-inst-float.rs @@ -47,6 +47,19 @@ impl Default for IntStr { } } } +#[test] +fn __bindgen_test_layout_foo_open0_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < foo < ::std::os::raw::c_int > > (), 4usize, + concat!("Size of template specialization: ", stringify!(foo < + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < foo < ::std::os::raw::c_int > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(foo < + ::std::os::raw::c_int >)) + ); +} /// Cannot derive Hash/Eq/Ord when instantiated with float but can derive PartialEq/PartialOrd #[repr(C)] #[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] @@ -80,19 +93,6 @@ impl Default for FloatStr { } } #[test] -fn __bindgen_test_layout_foo_open0_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < foo < ::std::os::raw::c_int > > (), 4usize, - concat!("Size of template specialization: ", stringify!(foo < - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < foo < ::std::os::raw::c_int > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(foo < - ::std::os::raw::c_int >)) - ); -} -#[test] fn __bindgen_test_layout_foo_open0_float_close0_instantiation() { assert_eq!( ::std::mem::size_of:: < foo < f32 > > (), 4usize, diff --git a/bindgen-tests/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs b/bindgen-tests/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs index 1902b1b971..3075bf1f5a 100644 --- a/bindgen-tests/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs +++ b/bindgen-tests/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs @@ -44,6 +44,19 @@ impl Default for DerivedWithNoVirtualMethods { } } } +#[test] +fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), + 16usize, concat!("Size of template specialization: ", stringify!(BaseWithVtable < + * mut ::std::os::raw::c_char >)) + ); + assert_eq!( + ::std::mem::align_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), + 8usize, concat!("Alignment of template specialization: ", + stringify!(BaseWithVtable < * mut ::std::os::raw::c_char >)) + ); +} /// This should not have an explicit vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -70,6 +83,19 @@ impl Default for DerivedWithVirtualMethods { } } } +#[test] +fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation_1() { + assert_eq!( + ::std::mem::size_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), + 16usize, concat!("Size of template specialization: ", stringify!(BaseWithVtable < + * mut ::std::os::raw::c_char >)) + ); + assert_eq!( + ::std::mem::align_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), + 8usize, concat!("Alignment of template specialization: ", + stringify!(BaseWithVtable < * mut ::std::os::raw::c_char >)) + ); +} /// This should not have any vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -115,6 +141,19 @@ impl Default for DerivedWithVtable { } } } +#[test] +fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < BaseWithoutVtable < * mut ::std::os::raw::c_char > > (), + 8usize, concat!("Size of template specialization: ", stringify!(BaseWithoutVtable + < * mut ::std::os::raw::c_char >)) + ); + assert_eq!( + ::std::mem::align_of:: < BaseWithoutVtable < * mut ::std::os::raw::c_char > > (), + 8usize, concat!("Alignment of template specialization: ", + stringify!(BaseWithoutVtable < * mut ::std::os::raw::c_char >)) + ); +} /// This should not have any vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -142,45 +181,6 @@ impl Default for DerivedWithoutVtable { } } #[test] -fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), - 16usize, concat!("Size of template specialization: ", stringify!(BaseWithVtable < - * mut ::std::os::raw::c_char >)) - ); - assert_eq!( - ::std::mem::align_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), - 8usize, concat!("Alignment of template specialization: ", - stringify!(BaseWithVtable < * mut ::std::os::raw::c_char >)) - ); -} -#[test] -fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation_1() { - assert_eq!( - ::std::mem::size_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), - 16usize, concat!("Size of template specialization: ", stringify!(BaseWithVtable < - * mut ::std::os::raw::c_char >)) - ); - assert_eq!( - ::std::mem::align_of:: < BaseWithVtable < * mut ::std::os::raw::c_char > > (), - 8usize, concat!("Alignment of template specialization: ", - stringify!(BaseWithVtable < * mut ::std::os::raw::c_char >)) - ); -} -#[test] -fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < BaseWithoutVtable < * mut ::std::os::raw::c_char > > (), - 8usize, concat!("Size of template specialization: ", stringify!(BaseWithoutVtable - < * mut ::std::os::raw::c_char >)) - ); - assert_eq!( - ::std::mem::align_of:: < BaseWithoutVtable < * mut ::std::os::raw::c_char > > (), - 8usize, concat!("Alignment of template specialization: ", - stringify!(BaseWithoutVtable < * mut ::std::os::raw::c_char >)) - ); -} -#[test] fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation_1() { assert_eq!( ::std::mem::size_of:: < BaseWithoutVtable < * mut ::std::os::raw::c_char > > (), diff --git a/bindgen-tests/tests/expectations/tests/inner-typedef-gh422.rs b/bindgen-tests/tests/expectations/tests/inner-typedef-gh422.rs index 0cc6880b44..d3f2c0ede1 100644 --- a/bindgen-tests/tests/expectations/tests/inner-typedef-gh422.rs +++ b/bindgen-tests/tests/expectations/tests/inner-typedef-gh422.rs @@ -20,12 +20,12 @@ impl Default for Foo_InnerType { } } pub type Bar = InnerType; -extern "C" { - #[link_name = "\u{1}_Z4funcv"] - pub fn func() -> Bar; -} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct InnerType { pub _address: u8, } +extern "C" { + #[link_name = "\u{1}_Z4funcv"] + pub fn func() -> Bar; +} diff --git a/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs b/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs index d602ff8835..6137bfcd50 100644 --- a/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs +++ b/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs @@ -76,10 +76,6 @@ impl Default for nsIContent { } } } -extern "C" { - #[link_name = "\u{1}_Z35Gecko_GetAnonymousContentForElementv"] - pub fn Gecko_GetAnonymousContentForElement() -> *mut nsTArray; -} #[test] fn __bindgen_test_layout_nsTArray_open0_ptr_nsIContent_close0_instantiation() { assert_eq!( @@ -91,6 +87,10 @@ fn __bindgen_test_layout_nsTArray_open0_ptr_nsIContent_close0_instantiation() { concat!("Alignment of template specialization: ", stringify!(nsTArray)) ); } +extern "C" { + #[link_name = "\u{1}_Z35Gecko_GetAnonymousContentForElementv"] + pub fn Gecko_GetAnonymousContentForElement() -> *mut nsTArray; +} #[test] fn __bindgen_test_layout_nsTArray_open0_ptr_nsIContent_close0_instantiation_1() { assert_eq!( diff --git a/bindgen-tests/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs b/bindgen-tests/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs index 2591c1aac5..5b371af6e5 100644 --- a/bindgen-tests/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs +++ b/bindgen-tests/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs @@ -26,9 +26,6 @@ fn bindgen_test_layout__bindgen_ty_1() { concat!("Offset of field: ", stringify!(_bindgen_ty_1), "::", stringify!(ar)) ); } -extern "C" { - pub static mut AutoIdVector: _bindgen_ty_1; -} #[test] fn __bindgen_test_layout_a_open0_int_close0_instantiation() { assert_eq!( @@ -40,3 +37,6 @@ fn __bindgen_test_layout_a_open0_int_close0_instantiation() { concat!("Alignment of template specialization: ", stringify!(a)) ); } +extern "C" { + pub static mut AutoIdVector: _bindgen_ty_1; +} diff --git a/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs b/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs index 96bbfe4c1b..55d8749bfe 100644 --- a/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs +++ b/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs @@ -62,6 +62,17 @@ impl Default for g { } } } +#[test] +fn __bindgen_test_layout_f_open0_e_open1_int_close1_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < f > (), 1usize, + concat!("Size of template specialization: ", stringify!(f)) + ); + assert_eq!( + ::std::mem::align_of:: < f > (), 1usize, + concat!("Alignment of template specialization: ", stringify!(f)) + ); +} #[repr(C)] pub struct b { pub _base: g, @@ -88,14 +99,3 @@ extern "C" { #[link_name = "\u{1}_Z25Servo_Element_GetSnapshotv"] pub fn Servo_Element_GetSnapshot() -> A; } -#[test] -fn __bindgen_test_layout_f_open0_e_open1_int_close1_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < f > (), 1usize, - concat!("Size of template specialization: ", stringify!(f)) - ); - assert_eq!( - ::std::mem::align_of:: < f > (), 1usize, - concat!("Alignment of template specialization: ", stringify!(f)) - ); -} diff --git a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque.rs b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque.rs index cfbf2f61cc..4ec58e7825 100644 --- a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque.rs +++ b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque.rs @@ -84,8 +84,6 @@ where } } pub const JSVAL_TAG_SHIFT: u32 = 47; -pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327; -pub const JSVAL_TAG_MASK: i64 = -140737488355328; #[repr(u8)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum JSValueType { @@ -127,6 +125,8 @@ pub enum JSValueShiftedTag { JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, } +pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327; +pub const JSVAL_TAG_MASK: i64 = -140737488355328; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum JSWhyMagic { diff --git a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs index b97bbac96f..fa55d5c1ce 100644 --- a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs +++ b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs @@ -127,8 +127,6 @@ impl ::std::cmp::PartialEq for __BindgenUnionField { } impl ::std::cmp::Eq for __BindgenUnionField {} pub const JSVAL_TAG_SHIFT: u32 = 47; -pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327; -pub const JSVAL_TAG_MASK: i64 = -140737488355328; #[repr(u8)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum JSValueType { @@ -170,6 +168,8 @@ pub enum JSValueShiftedTag { JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, } +pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327; +pub const JSVAL_TAG_MASK: i64 = -140737488355328; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum JSWhyMagic { diff --git a/bindgen-tests/tests/expectations/tests/layout_arp.rs b/bindgen-tests/tests/expectations/tests/layout_arp.rs index 1ee045593f..ee6bdf01a8 100644 --- a/bindgen-tests/tests/expectations/tests/layout_arp.rs +++ b/bindgen-tests/tests/expectations/tests/layout_arp.rs @@ -1,12 +1,5 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] pub const ETHER_ADDR_LEN: u32 = 6; -pub const ARP_HRD_ETHER: u32 = 1; -pub const ARP_OP_REQUEST: u32 = 1; -pub const ARP_OP_REPLY: u32 = 2; -pub const ARP_OP_REVREQUEST: u32 = 3; -pub const ARP_OP_REVREPLY: u32 = 4; -pub const ARP_OP_INVREQUEST: u32 = 8; -pub const ARP_OP_INVREPLY: u32 = 9; /** Ethernet address: A universally administered address is uniquely assigned to a device by its manufacturer. The first three octets (in transmission order) contain the @@ -133,3 +126,10 @@ fn bindgen_test_layout_arp_hdr() { stringify!(arp_data)) ); } +pub const ARP_HRD_ETHER: u32 = 1; +pub const ARP_OP_REQUEST: u32 = 1; +pub const ARP_OP_REPLY: u32 = 2; +pub const ARP_OP_REVREQUEST: u32 = 3; +pub const ARP_OP_REVREPLY: u32 = 4; +pub const ARP_OP_INVREQUEST: u32 = 8; +pub const ARP_OP_INVREPLY: u32 = 9; diff --git a/bindgen-tests/tests/expectations/tests/layout_array.rs b/bindgen-tests/tests/expectations/tests/layout_array.rs index d9171be24b..3654c62c7c 100644 --- a/bindgen-tests/tests/expectations/tests/layout_array.rs +++ b/bindgen-tests/tests/expectations/tests/layout_array.rs @@ -1,13 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] pub const RTE_CACHE_LINE_SIZE: u32 = 64; pub const RTE_MEMPOOL_OPS_NAMESIZE: u32 = 32; -pub const RTE_MEMPOOL_MAX_OPS_IDX: u32 = 16; -pub const RTE_HEAP_NUM_FREELISTS: u32 = 13; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct rte_mempool { - _unused: [u8; 0], -} /** Prototype for implementation specific data provisioning function. The function should provide the implementation specific memory for @@ -19,6 +12,11 @@ pub struct rte_mempool { pub type rte_mempool_alloc_t = ::std::option::Option< unsafe extern "C" fn(mp: *mut rte_mempool) -> ::std::os::raw::c_int, >; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rte_mempool { + _unused: [u8; 0], +} /// Free the opaque private data pointed to by mp->pool_data pointer. pub type rte_mempool_free_t = ::std::option::Option< unsafe extern "C" fn(mp: *mut rte_mempool), @@ -118,6 +116,7 @@ impl ::std::cmp::PartialEq for rte_mempool_ops { && self.get_count == other.get_count } } +pub const RTE_MEMPOOL_MAX_OPS_IDX: u32 = 16; /// The rte_spinlock_t type. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -199,6 +198,7 @@ impl Default for rte_mempool_ops_table { } } } +pub const RTE_HEAP_NUM_FREELISTS: u32 = 13; /// Structure to hold malloc heap #[repr(C)] #[repr(align(64))] diff --git a/bindgen-tests/tests/expectations/tests/layout_array_too_long.rs b/bindgen-tests/tests/expectations/tests/layout_array_too_long.rs index 2eb95b2d85..62e616a66f 100644 --- a/bindgen-tests/tests/expectations/tests/layout_array_too_long.rs +++ b/bindgen-tests/tests/expectations/tests/layout_array_too_long.rs @@ -61,6 +61,12 @@ impl Default for ip_frag { } } } +///< fragment mbuf +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct rte_mbuf { + pub _address: u8, +} /// @internal to uniquely indetify fragmented datagram. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -217,9 +223,3 @@ impl ::std::cmp::PartialEq for ip_frag_pkt { && self.last_idx == other.last_idx && self.frags == other.frags } } -///< fragment mbuf -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct rte_mbuf { - pub _address: u8, -} diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs index 1ec0744f0d..6db7dcf27d 100644 --- a/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs +++ b/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs @@ -90,31 +90,6 @@ pub const ETH_VMDQ_MAX_VLAN_FILTERS: u32 = 64; pub const ETH_DCB_NUM_USER_PRIORITIES: u32 = 8; pub const ETH_VMDQ_DCB_NUM_QUEUES: u32 = 128; pub const ETH_DCB_NUM_QUEUES: u32 = 128; -pub const RTE_ETH_FDIR_MAX_FLEXLEN: u32 = 16; -pub const RTE_ETH_INSET_SIZE_MAX: u32 = 128; -pub const RTE_ETH_FLOW_UNKNOWN: u32 = 0; -pub const RTE_ETH_FLOW_RAW: u32 = 1; -pub const RTE_ETH_FLOW_IPV4: u32 = 2; -pub const RTE_ETH_FLOW_FRAG_IPV4: u32 = 3; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: u32 = 4; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: u32 = 5; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: u32 = 6; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: u32 = 7; -pub const RTE_ETH_FLOW_IPV6: u32 = 8; -pub const RTE_ETH_FLOW_FRAG_IPV6: u32 = 9; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: u32 = 10; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: u32 = 11; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: u32 = 12; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: u32 = 13; -pub const RTE_ETH_FLOW_L2_PAYLOAD: u32 = 14; -pub const RTE_ETH_FLOW_IPV6_EX: u32 = 15; -pub const RTE_ETH_FLOW_IPV6_TCP_EX: u32 = 16; -pub const RTE_ETH_FLOW_IPV6_UDP_EX: u32 = 17; -pub const RTE_ETH_FLOW_PORT: u32 = 18; -pub const RTE_ETH_FLOW_VXLAN: u32 = 19; -pub const RTE_ETH_FLOW_GENEVE: u32 = 20; -pub const RTE_ETH_FLOW_NVGRE: u32 = 21; -pub const RTE_ETH_FLOW_MAX: u32 = 22; #[repr(u32)] /** A set of values to identify what method is to be used to route packets to multiple queues.*/ @@ -1203,6 +1178,30 @@ fn bindgen_test_layout_rte_eth_fdir_masks() { stringify!(tunnel_type_mask)) ); } +pub const RTE_ETH_FDIR_MAX_FLEXLEN: u32 = 16; +pub const RTE_ETH_INSET_SIZE_MAX: u32 = 128; +pub const RTE_ETH_FLOW_UNKNOWN: u32 = 0; +pub const RTE_ETH_FLOW_RAW: u32 = 1; +pub const RTE_ETH_FLOW_IPV4: u32 = 2; +pub const RTE_ETH_FLOW_FRAG_IPV4: u32 = 3; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: u32 = 4; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: u32 = 5; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: u32 = 6; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: u32 = 7; +pub const RTE_ETH_FLOW_IPV6: u32 = 8; +pub const RTE_ETH_FLOW_FRAG_IPV6: u32 = 9; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: u32 = 10; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: u32 = 11; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: u32 = 12; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: u32 = 13; +pub const RTE_ETH_FLOW_L2_PAYLOAD: u32 = 14; +pub const RTE_ETH_FLOW_IPV6_EX: u32 = 15; +pub const RTE_ETH_FLOW_IPV6_TCP_EX: u32 = 16; +pub const RTE_ETH_FLOW_IPV6_UDP_EX: u32 = 17; +pub const RTE_ETH_FLOW_PORT: u32 = 18; +pub const RTE_ETH_FLOW_VXLAN: u32 = 19; +pub const RTE_ETH_FLOW_GENEVE: u32 = 20; +pub const RTE_ETH_FLOW_NVGRE: u32 = 21; #[repr(u32)] /// Payload type #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -1286,6 +1285,7 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() { stringify!(mask)) ); } +pub const RTE_ETH_FLOW_MAX: u32 = 22; /** A structure used to define all flexible payload related setting include flex payload and flex mask*/ #[repr(C)] diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs index 086384c450..5f3e4e26ea 100644 --- a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs +++ b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs @@ -133,31 +133,6 @@ pub const ETH_VMDQ_MAX_VLAN_FILTERS: u32 = 64; pub const ETH_DCB_NUM_USER_PRIORITIES: u32 = 8; pub const ETH_VMDQ_DCB_NUM_QUEUES: u32 = 128; pub const ETH_DCB_NUM_QUEUES: u32 = 128; -pub const RTE_ETH_FDIR_MAX_FLEXLEN: u32 = 16; -pub const RTE_ETH_INSET_SIZE_MAX: u32 = 128; -pub const RTE_ETH_FLOW_UNKNOWN: u32 = 0; -pub const RTE_ETH_FLOW_RAW: u32 = 1; -pub const RTE_ETH_FLOW_IPV4: u32 = 2; -pub const RTE_ETH_FLOW_FRAG_IPV4: u32 = 3; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: u32 = 4; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: u32 = 5; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: u32 = 6; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: u32 = 7; -pub const RTE_ETH_FLOW_IPV6: u32 = 8; -pub const RTE_ETH_FLOW_FRAG_IPV6: u32 = 9; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: u32 = 10; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: u32 = 11; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: u32 = 12; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: u32 = 13; -pub const RTE_ETH_FLOW_L2_PAYLOAD: u32 = 14; -pub const RTE_ETH_FLOW_IPV6_EX: u32 = 15; -pub const RTE_ETH_FLOW_IPV6_TCP_EX: u32 = 16; -pub const RTE_ETH_FLOW_IPV6_UDP_EX: u32 = 17; -pub const RTE_ETH_FLOW_PORT: u32 = 18; -pub const RTE_ETH_FLOW_VXLAN: u32 = 19; -pub const RTE_ETH_FLOW_GENEVE: u32 = 20; -pub const RTE_ETH_FLOW_NVGRE: u32 = 21; -pub const RTE_ETH_FLOW_MAX: u32 = 22; #[repr(u32)] /** A set of values to identify what method is to be used to route packets to multiple queues.*/ @@ -1316,6 +1291,30 @@ impl Clone for rte_eth_fdir_masks { *self } } +pub const RTE_ETH_FDIR_MAX_FLEXLEN: u32 = 16; +pub const RTE_ETH_INSET_SIZE_MAX: u32 = 128; +pub const RTE_ETH_FLOW_UNKNOWN: u32 = 0; +pub const RTE_ETH_FLOW_RAW: u32 = 1; +pub const RTE_ETH_FLOW_IPV4: u32 = 2; +pub const RTE_ETH_FLOW_FRAG_IPV4: u32 = 3; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: u32 = 4; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: u32 = 5; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: u32 = 6; +pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: u32 = 7; +pub const RTE_ETH_FLOW_IPV6: u32 = 8; +pub const RTE_ETH_FLOW_FRAG_IPV6: u32 = 9; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: u32 = 10; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: u32 = 11; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: u32 = 12; +pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: u32 = 13; +pub const RTE_ETH_FLOW_L2_PAYLOAD: u32 = 14; +pub const RTE_ETH_FLOW_IPV6_EX: u32 = 15; +pub const RTE_ETH_FLOW_IPV6_TCP_EX: u32 = 16; +pub const RTE_ETH_FLOW_IPV6_UDP_EX: u32 = 17; +pub const RTE_ETH_FLOW_PORT: u32 = 18; +pub const RTE_ETH_FLOW_VXLAN: u32 = 19; +pub const RTE_ETH_FLOW_GENEVE: u32 = 20; +pub const RTE_ETH_FLOW_NVGRE: u32 = 21; #[repr(u32)] /// Payload type #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -1409,6 +1408,7 @@ impl Clone for rte_eth_fdir_flex_mask { *self } } +pub const RTE_ETH_FLOW_MAX: u32 = 22; /** A structure used to define all flexible payload related setting include flex payload and flex mask*/ #[repr(C)] diff --git a/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs b/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs index d70e6237da..aed5b029f5 100644 --- a/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs +++ b/bindgen-tests/tests/expectations/tests/layout_large_align_field.rs @@ -91,6 +91,12 @@ impl Default for ip_frag { } } } +///< fragment mbuf +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct rte_mbuf { + pub _address: u8, +} /// @internal to uniquely indetify fragmented datagram. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -449,9 +455,3 @@ impl Default for rte_ip_frag_tbl { } } } -///< fragment mbuf -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct rte_mbuf { - pub _address: u8, -} diff --git a/bindgen-tests/tests/expectations/tests/libclang-5/issue-769-bad-instantiation-test.rs b/bindgen-tests/tests/expectations/tests/libclang-5/issue-769-bad-instantiation-test.rs index 0acb9ad8b8..0709e3eab9 100644 --- a/bindgen-tests/tests/expectations/tests/libclang-5/issue-769-bad-instantiation-test.rs +++ b/bindgen-tests/tests/expectations/tests/libclang-5/issue-769-bad-instantiation-test.rs @@ -18,7 +18,6 @@ pub mod root { } } } - pub type AutoValueVector_Alias = ::std::os::raw::c_int; #[test] fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() { assert_eq!( @@ -32,6 +31,7 @@ pub mod root { ::std::os::raw::c_int >)) ); } + pub type AutoValueVector_Alias = ::std::os::raw::c_int; #[test] fn __bindgen_test_layout_Rooted_open0_AutoValueVector_Alias_close0_instantiation() { assert_eq!( diff --git a/bindgen-tests/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs b/bindgen-tests/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs index 0483cdaf75..404e586f22 100644 --- a/bindgen-tests/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs +++ b/bindgen-tests/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs @@ -30,8 +30,6 @@ impl Default for Rooted { } } } -///
-pub type MaybeWrapped = a; #[test] fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { assert_eq!( @@ -45,3 +43,5 @@ fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { ::std::os::raw::c_int >)) ); } +///
+pub type MaybeWrapped
= a; diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/issue-769-bad-instantiation-test.rs b/bindgen-tests/tests/expectations/tests/libclang-9/issue-769-bad-instantiation-test.rs index 0acb9ad8b8..0709e3eab9 100644 --- a/bindgen-tests/tests/expectations/tests/libclang-9/issue-769-bad-instantiation-test.rs +++ b/bindgen-tests/tests/expectations/tests/libclang-9/issue-769-bad-instantiation-test.rs @@ -18,7 +18,6 @@ pub mod root { } } } - pub type AutoValueVector_Alias = ::std::os::raw::c_int; #[test] fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() { assert_eq!( @@ -32,6 +31,7 @@ pub mod root { ::std::os::raw::c_int >)) ); } + pub type AutoValueVector_Alias = ::std::os::raw::c_int; #[test] fn __bindgen_test_layout_Rooted_open0_AutoValueVector_Alias_close0_instantiation() { assert_eq!( diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/type_alias_template_specialized.rs b/bindgen-tests/tests/expectations/tests/libclang-9/type_alias_template_specialized.rs index 0483cdaf75..404e586f22 100644 --- a/bindgen-tests/tests/expectations/tests/libclang-9/type_alias_template_specialized.rs +++ b/bindgen-tests/tests/expectations/tests/libclang-9/type_alias_template_specialized.rs @@ -30,8 +30,6 @@ impl Default for Rooted { } } } -///
-pub type MaybeWrapped
= a; #[test] fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { assert_eq!( @@ -45,3 +43,5 @@ fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { ::std::os::raw::c_int >)) ); } +///
+pub type MaybeWrapped
= a; diff --git a/bindgen-tests/tests/expectations/tests/namespace.rs b/bindgen-tests/tests/expectations/tests/namespace.rs index 83543b851e..f0493944e9 100644 --- a/bindgen-tests/tests/expectations/tests/namespace.rs +++ b/bindgen-tests/tests/expectations/tests/namespace.rs @@ -3,6 +3,14 @@ pub mod root { #[allow(unused_imports)] use self::super::root; + pub mod faraway { + #[allow(unused_imports)] + use self::super::super::root; + extern "C" { + #[link_name = "\u{1}_ZN7faraway3barEv"] + pub fn bar(); + } + } extern "C" { #[link_name = "\u{1}_Z9top_levelv"] pub fn top_level(); @@ -101,12 +109,4 @@ pub mod root { pub fn foo(); } } - pub mod faraway { - #[allow(unused_imports)] - use self::super::super::root; - extern "C" { - #[link_name = "\u{1}_ZN7faraway3barEv"] - pub fn bar(); - } - } } diff --git a/bindgen-tests/tests/expectations/tests/opaque-template-instantiation.rs b/bindgen-tests/tests/expectations/tests/opaque-template-instantiation.rs index f35915f64c..4e19127019 100644 --- a/bindgen-tests/tests/expectations/tests/opaque-template-instantiation.rs +++ b/bindgen-tests/tests/expectations/tests/opaque-template-instantiation.rs @@ -46,6 +46,19 @@ impl Default for ContainsInstantiation { } } } +#[test] +fn __bindgen_test_layout_Template_open0_char_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < Template < ::std::os::raw::c_char > > (), 1usize, + concat!("Size of template specialization: ", stringify!(Template < + ::std::os::raw::c_char >)) + ); + assert_eq!( + ::std::mem::align_of:: < Template < ::std::os::raw::c_char > > (), 1usize, + concat!("Alignment of template specialization: ", stringify!(Template < + ::std::os::raw::c_char >)) + ); +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ContainsOpaqueInstantiation { @@ -69,16 +82,3 @@ fn bindgen_test_layout_ContainsOpaqueInstantiation() { stringify!(opaque)) ); } -#[test] -fn __bindgen_test_layout_Template_open0_char_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < Template < ::std::os::raw::c_char > > (), 1usize, - concat!("Size of template specialization: ", stringify!(Template < - ::std::os::raw::c_char >)) - ); - assert_eq!( - ::std::mem::align_of:: < Template < ::std::os::raw::c_char > > (), 1usize, - concat!("Alignment of template specialization: ", stringify!(Template < - ::std::os::raw::c_char >)) - ); -} diff --git a/bindgen-tests/tests/expectations/tests/template.rs b/bindgen-tests/tests/expectations/tests/template.rs index 4b9c99c31b..cf0d42fdad 100644 --- a/bindgen-tests/tests/expectations/tests/template.rs +++ b/bindgen-tests/tests/expectations/tests/template.rs @@ -35,6 +35,19 @@ extern "C" { #[link_name = "\u{1}_Z3bar3FooIiiE"] pub fn bar(foo: Foo<::std::os::raw::c_int>); } +#[test] +fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < Foo < ::std::os::raw::c_int > > (), 24usize, + concat!("Size of template specialization: ", stringify!(Foo < + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < Foo < ::std::os::raw::c_int > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(Foo < + ::std::os::raw::c_int >)) + ); +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mozilla_Foo { @@ -153,6 +166,210 @@ impl Default for C { } } } +#[test] +fn __bindgen_test_layout_B_open0_unsigned_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < ::std::os::raw::c_uint > > (), 4usize, + concat!("Size of template specialization: ", stringify!(B < + ::std::os::raw::c_uint >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < ::std::os::raw::c_uint > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(B < + ::std::os::raw::c_uint >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ptr_const_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * const + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(B < * const + ::std::os::raw::c_int >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ptr_const_mozilla__Foo_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * const mozilla_Foo > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * const mozilla_Foo + >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * const mozilla_Foo > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(B < * const + mozilla_Foo >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_array1_ptr_const_mozilla__Foo_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < [* const mozilla_Foo; 1usize] > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < [* const mozilla_Foo; + 1usize] >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < [* const mozilla_Foo; 1usize] > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(B < [* const + mozilla_Foo; 1usize] >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_const_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < ::std::os::raw::c_int > > (), 4usize, + concat!("Size of template specialization: ", stringify!(B < ::std::os::raw::c_int + >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < ::std::os::raw::c_int > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(B < + ::std::os::raw::c_int >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_volatile_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < ::std::os::raw::c_int > > (), 4usize, + concat!("Size of template specialization: ", stringify!(B < ::std::os::raw::c_int + >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < ::std::os::raw::c_int > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(B < + ::std::os::raw::c_int >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_const_bool_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < bool > > (), 1usize, + concat!("Size of template specialization: ", stringify!(B < bool >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < bool > > (), 1usize, + concat!("Alignment of template specialization: ", stringify!(B < bool >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_const_char16_t_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < u16 > > (), 2usize, + concat!("Size of template specialization: ", stringify!(B < u16 >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < u16 > > (), 2usize, + concat!("Alignment of template specialization: ", stringify!(B < u16 >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_array1_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, + concat!("Size of template specialization: ", stringify!(B < + [::std::os::raw::c_int; 1usize] >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(B < + [::std::os::raw::c_int; 1usize] >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_array1_ptr_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < [* mut ::std::os::raw::c_int; 1usize] > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < [* mut + ::std::os::raw::c_int; 1usize] >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < [* mut ::std::os::raw::c_int; 1usize] > > (), + 8usize, concat!("Alignment of template specialization: ", stringify!(B < [* mut + ::std::os::raw::c_int; 1usize] >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ptr_array1_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * mut + [::std::os::raw::c_int; 1usize] >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), + 8usize, concat!("Alignment of template specialization: ", stringify!(B < * mut + [::std::os::raw::c_int; 1usize] >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ref_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * mut ::std::os::raw::c_int > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * mut + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * mut ::std::os::raw::c_int > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(B < * mut + ::std::os::raw::c_int >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ref_const_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * const + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(B < * const + ::std::os::raw::c_int >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ref_ptr_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * mut * mut ::std::os::raw::c_int > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * mut * mut + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * mut * mut ::std::os::raw::c_int > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(B < * mut * mut + ::std::os::raw::c_int >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_ref_array1_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), 8usize, + concat!("Size of template specialization: ", stringify!(B < * mut + [::std::os::raw::c_int; 1usize] >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), + 8usize, concat!("Alignment of template specialization: ", stringify!(B < * mut + [::std::os::raw::c_int; 1usize] >)) + ); +} +#[test] +fn __bindgen_test_layout_B_open0_array1_const_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, + concat!("Size of template specialization: ", stringify!(B < + [::std::os::raw::c_int; 1usize] >)) + ); + assert_eq!( + ::std::mem::align_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(B < + [::std::os::raw::c_int; 1usize] >)) + ); +} #[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct D { @@ -184,6 +401,19 @@ impl Default for D { } } } +#[test] +fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() { + assert_eq!( + ::std::mem::size_of:: < Foo < ::std::os::raw::c_int > > (), 24usize, + concat!("Size of template specialization: ", stringify!(Foo < + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < Foo < ::std::os::raw::c_int > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(Foo < + ::std::os::raw::c_int >)) + ); +} #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rooted { @@ -201,6 +431,19 @@ impl Default for Rooted { } } } +#[test] +fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 24usize, + concat!("Size of template specialization: ", stringify!(Rooted < * mut + ::std::os::raw::c_void >)) + ); + assert_eq!( + ::std::mem::align_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(Rooted < * mut + ::std::os::raw::c_void >)) + ); +} #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RootedContainer { @@ -232,7 +475,33 @@ impl Default for RootedContainer { } } } +#[test] +fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation_1() { + assert_eq!( + ::std::mem::size_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 24usize, + concat!("Size of template specialization: ", stringify!(Rooted < * mut + ::std::os::raw::c_void >)) + ); + assert_eq!( + ::std::mem::align_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 8usize, + concat!("Alignment of template specialization: ", stringify!(Rooted < * mut + ::std::os::raw::c_void >)) + ); +} pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>; +#[test] +fn __bindgen_test_layout_WithDtor_open0_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < WithDtor < ::std::os::raw::c_int > > (), 4usize, + concat!("Size of template specialization: ", stringify!(WithDtor < + ::std::os::raw::c_int >)) + ); + assert_eq!( + ::std::mem::align_of:: < WithDtor < ::std::os::raw::c_int > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(WithDtor < + ::std::os::raw::c_int >)) + ); +} #[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct WithDtor { @@ -460,272 +729,3 @@ impl Default for ReplacedWithoutDestructorFwd { } } } -#[test] -fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < Foo < ::std::os::raw::c_int > > (), 24usize, - concat!("Size of template specialization: ", stringify!(Foo < - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < Foo < ::std::os::raw::c_int > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(Foo < - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_unsigned_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < ::std::os::raw::c_uint > > (), 4usize, - concat!("Size of template specialization: ", stringify!(B < - ::std::os::raw::c_uint >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < ::std::os::raw::c_uint > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(B < - ::std::os::raw::c_uint >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ptr_const_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * const - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(B < * const - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ptr_const_mozilla__Foo_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * const mozilla_Foo > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * const mozilla_Foo - >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * const mozilla_Foo > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(B < * const - mozilla_Foo >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_array1_ptr_const_mozilla__Foo_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < [* const mozilla_Foo; 1usize] > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < [* const mozilla_Foo; - 1usize] >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < [* const mozilla_Foo; 1usize] > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(B < [* const - mozilla_Foo; 1usize] >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_const_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < ::std::os::raw::c_int > > (), 4usize, - concat!("Size of template specialization: ", stringify!(B < ::std::os::raw::c_int - >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < ::std::os::raw::c_int > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(B < - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_volatile_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < ::std::os::raw::c_int > > (), 4usize, - concat!("Size of template specialization: ", stringify!(B < ::std::os::raw::c_int - >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < ::std::os::raw::c_int > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(B < - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_const_bool_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < bool > > (), 1usize, - concat!("Size of template specialization: ", stringify!(B < bool >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < bool > > (), 1usize, - concat!("Alignment of template specialization: ", stringify!(B < bool >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_const_char16_t_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < u16 > > (), 2usize, - concat!("Size of template specialization: ", stringify!(B < u16 >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < u16 > > (), 2usize, - concat!("Alignment of template specialization: ", stringify!(B < u16 >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_array1_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, - concat!("Size of template specialization: ", stringify!(B < - [::std::os::raw::c_int; 1usize] >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(B < - [::std::os::raw::c_int; 1usize] >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_array1_ptr_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < [* mut ::std::os::raw::c_int; 1usize] > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < [* mut - ::std::os::raw::c_int; 1usize] >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < [* mut ::std::os::raw::c_int; 1usize] > > (), - 8usize, concat!("Alignment of template specialization: ", stringify!(B < [* mut - ::std::os::raw::c_int; 1usize] >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ptr_array1_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * mut - [::std::os::raw::c_int; 1usize] >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), - 8usize, concat!("Alignment of template specialization: ", stringify!(B < * mut - [::std::os::raw::c_int; 1usize] >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ref_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * mut ::std::os::raw::c_int > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * mut - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * mut ::std::os::raw::c_int > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(B < * mut - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ref_const_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * const - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * const ::std::os::raw::c_int > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(B < * const - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ref_ptr_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * mut * mut ::std::os::raw::c_int > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * mut * mut - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * mut * mut ::std::os::raw::c_int > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(B < * mut * mut - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_ref_array1_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), 8usize, - concat!("Size of template specialization: ", stringify!(B < * mut - [::std::os::raw::c_int; 1usize] >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < * mut [::std::os::raw::c_int; 1usize] > > (), - 8usize, concat!("Alignment of template specialization: ", stringify!(B < * mut - [::std::os::raw::c_int; 1usize] >)) - ); -} -#[test] -fn __bindgen_test_layout_B_open0_array1_const_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, - concat!("Size of template specialization: ", stringify!(B < - [::std::os::raw::c_int; 1usize] >)) - ); - assert_eq!( - ::std::mem::align_of:: < B < [::std::os::raw::c_int; 1usize] > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(B < - [::std::os::raw::c_int; 1usize] >)) - ); -} -#[test] -fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() { - assert_eq!( - ::std::mem::size_of:: < Foo < ::std::os::raw::c_int > > (), 24usize, - concat!("Size of template specialization: ", stringify!(Foo < - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < Foo < ::std::os::raw::c_int > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(Foo < - ::std::os::raw::c_int >)) - ); -} -#[test] -fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 24usize, - concat!("Size of template specialization: ", stringify!(Rooted < * mut - ::std::os::raw::c_void >)) - ); - assert_eq!( - ::std::mem::align_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(Rooted < * mut - ::std::os::raw::c_void >)) - ); -} -#[test] -fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation_1() { - assert_eq!( - ::std::mem::size_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 24usize, - concat!("Size of template specialization: ", stringify!(Rooted < * mut - ::std::os::raw::c_void >)) - ); - assert_eq!( - ::std::mem::align_of:: < Rooted < * mut ::std::os::raw::c_void > > (), 8usize, - concat!("Alignment of template specialization: ", stringify!(Rooted < * mut - ::std::os::raw::c_void >)) - ); -} -#[test] -fn __bindgen_test_layout_WithDtor_open0_int_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < WithDtor < ::std::os::raw::c_int > > (), 4usize, - concat!("Size of template specialization: ", stringify!(WithDtor < - ::std::os::raw::c_int >)) - ); - assert_eq!( - ::std::mem::align_of:: < WithDtor < ::std::os::raw::c_int > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(WithDtor < - ::std::os::raw::c_int >)) - ); -} diff --git a/bindgen-tests/tests/expectations/tests/template_instantiation_with_fn_local_type.rs b/bindgen-tests/tests/expectations/tests/template_instantiation_with_fn_local_type.rs index ab87b4160b..545aa15034 100644 --- a/bindgen-tests/tests/expectations/tests/template_instantiation_with_fn_local_type.rs +++ b/bindgen-tests/tests/expectations/tests/template_instantiation_with_fn_local_type.rs @@ -4,10 +4,6 @@ pub struct Foo { pub _address: u8, } -extern "C" { - #[link_name = "\u{1}_Z1fv"] - pub fn f(); -} #[test] fn __bindgen_test_layout_Foo_open0_Bar_close0_instantiation() { assert_eq!( @@ -19,6 +15,10 @@ fn __bindgen_test_layout_Foo_open0_Bar_close0_instantiation() { concat!("Alignment of template specialization: ", stringify!(Foo)) ); } +extern "C" { + #[link_name = "\u{1}_Z1fv"] + pub fn f(); +} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Baz { @@ -34,17 +34,6 @@ fn bindgen_test_layout_Baz() { stringify!(Baz)) ); } -#[test] -fn __bindgen_test_layout_Foo_open0_Boo_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < Foo > (), 1usize, - concat!("Size of template specialization: ", stringify!(Foo)) - ); - assert_eq!( - ::std::mem::align_of:: < Foo > (), 1usize, - concat!("Alignment of template specialization: ", stringify!(Foo)) - ); -} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { @@ -60,6 +49,17 @@ fn bindgen_test_layout_Bar() { stringify!(Bar)) ); } +#[test] +fn __bindgen_test_layout_Foo_open0_Boo_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < Foo > (), 1usize, + concat!("Size of template specialization: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of:: < Foo > (), 1usize, + concat!("Alignment of template specialization: ", stringify!(Foo)) + ); +} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Boo { diff --git a/bindgen-tests/tests/expectations/tests/transform-op.rs b/bindgen-tests/tests/expectations/tests/transform-op.rs index 3e7730bcea..1f910dada5 100644 --- a/bindgen-tests/tests/expectations/tests/transform-op.rs +++ b/bindgen-tests/tests/expectations/tests/transform-op.rs @@ -137,6 +137,17 @@ impl Default for StyleFoo__bindgen_ty_1 { } } } +#[test] +fn __bindgen_test_layout_StylePoint_open0_float_close0_instantiation() { + assert_eq!( + ::std::mem::size_of:: < StylePoint < f32 > > (), 8usize, + concat!("Size of template specialization: ", stringify!(StylePoint < f32 >)) + ); + assert_eq!( + ::std::mem::align_of:: < StylePoint < f32 > > (), 4usize, + concat!("Alignment of template specialization: ", stringify!(StylePoint < f32 >)) + ); +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct StyleBar { @@ -215,17 +226,6 @@ impl Default for StyleBar { } } #[test] -fn __bindgen_test_layout_StylePoint_open0_float_close0_instantiation() { - assert_eq!( - ::std::mem::size_of:: < StylePoint < f32 > > (), 8usize, - concat!("Size of template specialization: ", stringify!(StylePoint < f32 >)) - ); - assert_eq!( - ::std::mem::align_of:: < StylePoint < f32 > > (), 4usize, - concat!("Alignment of template specialization: ", stringify!(StylePoint < f32 >)) - ); -} -#[test] fn __bindgen_test_layout_StylePoint_open0_float_close0_instantiation_1() { assert_eq!( ::std::mem::size_of:: < StylePoint < f32 > > (), 8usize, diff --git a/bindgen/clang.rs b/bindgen/clang.rs index 0060213336..e8ec8cadba 100644 --- a/bindgen/clang.rs +++ b/bindgen/clang.rs @@ -6,6 +6,7 @@ use crate::ir::context::BindgenContext; use clang_sys::*; +use std::cmp; use std::ffi::{CStr, CString}; use std::fmt; use std::hash::Hash; @@ -1524,6 +1525,43 @@ impl SourceLocation { } } +impl SourceLocation { + /// Compare source locations, also considering `#include` directives. + pub(crate) fn partial_cmp_with_context( + &self, + other: &Self, + ctx: Option<&BindgenContext>, + ) -> Option { + let (file, _, _, offset) = self.location(); + let (other_file, _, _, other_offset) = other.location(); + + match (file.name(), other_file.name()) { + (Some(file), Some(other_file)) if file == other_file => { + offset.partial_cmp(&other_offset) + } + (Some(file), Some(other_file)) => { + if let Some(other_offset) = + ctx?.included_file_offset(file.clone(), other_file.clone()) + { + return offset.partial_cmp(&other_offset); + } + + if let Some(offset) = + ctx?.included_file_offset(other_file, file) + { + return other_offset.partial_cmp(&offset); + } + + None + } + // Built-in definitions should come first. + (Some(_), None) => Some(cmp::Ordering::Greater), + (None, Some(_)) => Some(cmp::Ordering::Less), + (None, None) => Some(cmp::Ordering::Equal), + } + } +} + impl fmt::Display for SourceLocation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let (file, line, col, _) = self.location(); diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index 47f23193cb..57494c9a6e 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -269,6 +269,8 @@ struct CodegenResult<'a> { /// that name. This lets us give each overload a unique suffix. overload_counters: HashMap, + overload_counts: HashMap, + items_to_serialize: Vec, } @@ -287,6 +289,7 @@ impl<'a> CodegenResult<'a> { functions_seen: Default::default(), vars_seen: Default::default(), overload_counters: Default::default(), + overload_counts: Default::default(), items_to_serialize: Default::default(), } } @@ -341,6 +344,14 @@ impl<'a> CodegenResult<'a> { number } + fn set_overload_count(&mut self, id: ItemId, count: u32) { + self.overload_counts.insert(id, count); + } + + fn overload_count(&self, id: &ItemId) -> Option { + self.overload_counts.get(id).cloned() + } + fn seen_var(&self, name: &str) -> bool { self.vars_seen.contains(name) } @@ -550,13 +561,29 @@ impl CodeGenerator for Module { let codegen_self = |result: &mut CodegenResult, found_any: &mut bool| { + let mut children = vec![]; + for child in self.children() { if ctx.codegen_items().contains(child) { *found_any = true; - ctx.resolve_item(*child).codegen(ctx, result, &()); + children.push(ctx.resolve_item(*child)); } } + children.sort_by(|child1, child2| { + child1 + .location() + .zip(child2.location()) + .and_then(|(location1, location2)| { + location1.partial_cmp_with_context(location2, Some(ctx)) + }) + .unwrap_or(std::cmp::Ordering::Equal) + }); + + for child in children { + child.codegen(ctx, result, &()); + } + if item.id() == ctx.root_module() { if result.saw_block { utils::prepend_block_header(ctx, &mut *result); @@ -2544,14 +2571,18 @@ impl Method { // First of all, output the actual function. let function_item = ctx.resolve_item(self.signature()); - if !function_item.process_before_codegen(ctx, result) { - return; - } let function = function_item.expect_function(); - let times_seen = function.codegen(ctx, result, function_item); - let times_seen = match times_seen { - Some(seen) => seen, - None => return, + let times_seen = if let Some(times_seen) = + result.overload_count(&function_item.id()) + { + times_seen + } else { + if !function_item.process_before_codegen(ctx, result) { + return; + } + + let Some(times_seen) = function.codegen(ctx, result, function_item) else { return }; + times_seen }; let signature_item = ctx.resolve_item(function.signature()); let mut name = match self.kind() { @@ -4137,8 +4168,7 @@ impl TryToRustTy for FunctionSig { impl CodeGenerator for Function { type Extra = Item; - /// If we've actually generated the symbol, the number of times we've seen - /// it. + /// If we've actually generated the symbol, the number of times we've seen it. type Return = Option; fn codegen( @@ -4305,6 +4335,7 @@ impl CodeGenerator for Function { // Handle overloaded functions by giving each overload its own unique // suffix. let times_seen = result.overload_number(&canonical_name); + result.set_overload_count(item.id(), times_seen); if times_seen > 0 { write!(&mut canonical_name, "{}", times_seen).unwrap(); } diff --git a/bindgen/deps.rs b/bindgen/deps.rs index 2edeaa8886..e348fa1303 100644 --- a/bindgen/deps.rs +++ b/bindgen/deps.rs @@ -9,7 +9,7 @@ pub(crate) struct DepfileSpec { impl DepfileSpec { pub fn write(&self, deps: &BTreeSet) -> std::io::Result<()> { - std::fs::write(&self.depfile_path, &self.to_string(deps)) + std::fs::write(&self.depfile_path, self.to_string(deps)) } fn to_string(&self, deps: &BTreeSet) -> String { diff --git a/bindgen/ir/context.rs b/bindgen/ir/context.rs index ee07625430..20784c2dfd 100644 --- a/bindgen/ir/context.rs +++ b/bindgen/ir/context.rs @@ -356,6 +356,11 @@ pub(crate) struct BindgenContext { /// This needs to be an std::HashMap because the cexpr API requires it. parsed_macros: StdHashMap, cexpr::expr::EvalResult>, + /// A map with all include locations. + /// + /// This is needed so that items are created in the order they are defined in. + includes: StdHashMap<(String, String), usize>, + /// A set of all the included filenames. deps: BTreeSet, @@ -560,6 +565,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" BindgenContext { items: vec![Some(root_module)], + includes: Default::default(), deps, types: Default::default(), type_params: Default::default(), @@ -635,11 +641,28 @@ If you encounter an error missing from this list, please file an issue or a PR!" } /// Add another path to the set of included files. - pub(crate) fn include_file(&mut self, filename: String) { + pub(crate) fn include_file( + &mut self, + source_file: String, + offset: usize, + included_file: String, + ) { for cb in &self.options().parse_callbacks { - cb.include_file(&filename); + cb.include_file(&included_file); } - self.deps.insert(filename); + self.deps.insert(included_file.clone()); + + let key = (source_file, included_file); + self.includes.entry(key).or_insert(offset); + } + + /// Get the offset of the `#include` directive for the `included_file` in the `source_file`. + pub(crate) fn included_file_offset( + &self, + source_file: String, + included_file: String, + ) -> Option { + self.includes.get(&(source_file, included_file)).cloned() } /// Get any included files. diff --git a/bindgen/ir/item.rs b/bindgen/ir/item.rs index f4dce45d83..1052c8b9e5 100644 --- a/bindgen/ir/item.rs +++ b/bindgen/ir/item.rs @@ -1461,7 +1461,12 @@ impl Item { ); } Some(filename) => { - ctx.include_file(filename); + let location = cursor.location(); + + let (file, _, _, offset) = location.location(); + let source_file = file.name().unwrap(); + + ctx.include_file(source_file, offset, filename); } } }