File tree 5 files changed +42
-2
lines changed 5 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -669,11 +669,11 @@ impl CodeGenerator for CompInfo {
669
669
for arg in self . template_args ( ) {
670
670
if let Some ( name) = ctx. resolve_type ( * arg) . name ( ) {
671
671
// hope this isn't bad
672
- types. push_str ( format ! ( "{}_ " , name) . as_str ( ) ) ;
672
+ types. push_str ( format ! ( "_{} " , name) . as_str ( ) ) ;
673
673
}
674
674
}
675
675
676
- let fn_name = format ! ( "bindgen_test_layout_template_{}_ {}" , canonical_name, types) ;
676
+ let fn_name = format ! ( "bindgen_test_layout_template_{}{}" , canonical_name, types) ;
677
677
let fn_name = ctx. rust_ident_raw ( & fn_name) ;
678
678
let ident = item. to_rust_ty ( ctx) ;
679
679
let prefix = ctx. trait_prefix ( ) ;
Original file line number Diff line number Diff line change @@ -75,3 +75,10 @@ fn bindgen_test_layout_ErrorResult() {
75
75
impl Clone for ErrorResult {
76
76
fn clone ( & self ) -> Self { * self }
77
77
}
78
+ #[ test]
79
+ fn bindgen_test_layout_template_TErrorResult_int ( ) {
80
+ assert_eq ! ( :: std:: mem:: size_of:: <TErrorResult <:: std:: os:: raw:: c_int>>( ) ,
81
+ 24usize ) ;
82
+ assert_eq ! ( :: std:: mem:: align_of:: <TErrorResult <:: std:: os:: raw:: c_int>>( ) ,
83
+ 8usize ) ;
84
+ }
Original file line number Diff line number Diff line change @@ -20,3 +20,10 @@ fn bindgen_test_layout_WithoutDtor() {
20
20
assert_eq ! ( :: std:: mem:: size_of:: <WithoutDtor >( ) , 8usize ) ;
21
21
assert_eq ! ( :: std:: mem:: align_of:: <WithoutDtor >( ) , 8usize ) ;
22
22
}
23
+ #[ test]
24
+ fn bindgen_test_layout_template_HandleWithDtor_int ( ) {
25
+ assert_eq ! ( :: std:: mem:: size_of:: <HandleWithDtor <:: std:: os:: raw:: c_int>>( )
26
+ , 8usize ) ;
27
+ assert_eq ! ( :: std:: mem:: align_of:: <HandleWithDtor <:: std:: os:: raw:: c_int>>( )
28
+ , 8usize ) ;
29
+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ fn bindgen_test_layout_Derived() {
23
23
impl Clone for Derived {
24
24
fn clone ( & self ) -> Self { * self }
25
25
}
26
+ #[ test]
27
+ fn bindgen_test_layout_template_Base ( ) {
28
+ assert_eq ! ( :: std:: mem:: size_of:: <Base <Derived >>( ) , 1usize ) ;
29
+ assert_eq ! ( :: std:: mem:: align_of:: <Base <Derived >>( ) , 1usize ) ;
30
+ }
26
31
#[ repr( C ) ]
27
32
#[ derive( Debug ) ]
28
33
pub struct BaseWithDestructor < T > {
@@ -41,3 +46,10 @@ fn bindgen_test_layout_DerivedFromBaseWithDestructor() {
41
46
assert_eq ! ( :: std:: mem:: align_of:: <DerivedFromBaseWithDestructor >( ) ,
42
47
1usize ) ;
43
48
}
49
+ #[ test]
50
+ fn bindgen_test_layout_template_BaseWithDestructor ( ) {
51
+ assert_eq ! ( :: std:: mem:: size_of:: <BaseWithDestructor <DerivedFromBaseWithDestructor >>( )
52
+ , 1usize ) ;
53
+ assert_eq ! ( :: std:: mem:: align_of:: <BaseWithDestructor <DerivedFromBaseWithDestructor >>( )
54
+ , 1usize ) ;
55
+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ pub struct Foo<T, U> {
12
12
pub m_member_arr : [ T ; 1usize ] ,
13
13
pub _phantom_1 : :: std:: marker:: PhantomData < U > ,
14
14
}
15
+ #[ test]
16
+ fn bindgen_test_layout_template_Foo_int_int ( ) {
17
+ assert_eq ! ( :: std:: mem:: size_of:: <Foo <:: std:: os:: raw:: c_int, :: std:: os:: raw:: c_int>>( )
18
+ , 24usize ) ;
19
+ assert_eq ! ( :: std:: mem:: align_of:: <Foo <:: std:: os:: raw:: c_int, :: std:: os:: raw:: c_int>>( )
20
+ , 8usize ) ;
21
+ }
15
22
extern "C" {
16
23
#[ link_name = "_Z3bar3FooIiiE" ]
17
24
pub fn bar ( foo : Foo < :: std:: os:: raw:: c_int , :: std:: os:: raw:: c_int > ) ;
@@ -168,3 +175,10 @@ pub struct TemplateWithVar<T> {
168
175
pub _address : u8 ,
169
176
pub _phantom_0 : :: std:: marker:: PhantomData < T > ,
170
177
}
178
+ #[ test]
179
+ fn bindgen_test_layout_template_WithDtor_int ( ) {
180
+ assert_eq ! ( :: std:: mem:: size_of:: <WithDtor <:: std:: os:: raw:: c_int>>( ) ,
181
+ 4usize ) ;
182
+ assert_eq ! ( :: std:: mem:: align_of:: <WithDtor <:: std:: os:: raw:: c_int>>( ) ,
183
+ 4usize ) ;
184
+ }
You can’t perform that action at this time.
0 commit comments