File tree 2 files changed +9
-15
lines changed
2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -1612,10 +1612,13 @@ impl CodeGenerator for CompInfo {
1612
1612
fields. push ( padding_field) ;
1613
1613
}
1614
1614
1615
- if let Some ( align_field) =
1616
- layout. and_then ( |layout| struct_layout. align_struct ( layout) )
1617
- {
1618
- fields. push ( align_field) ;
1615
+ if let Some ( layout) = layout {
1616
+ if struct_layout. requires_explicit_align ( layout) {
1617
+ let ty = helpers:: blob ( Layout :: new ( 0 , layout. align ) ) ;
1618
+ fields. push ( quote ! {
1619
+ pub __bindgen_align: #ty ,
1620
+ } ) ;
1621
+ }
1619
1622
}
1620
1623
}
1621
1624
Original file line number Diff line number Diff line change @@ -288,18 +288,9 @@ impl<'a> StructLayoutTracker<'a> {
288
288
}
289
289
}
290
290
291
- pub fn align_struct ( & self , layout : Layout ) -> Option < quote :: Tokens > {
292
- if self . max_field_align < layout. align &&
291
+ pub fn requires_explicit_align ( & self , layout : Layout ) -> bool {
292
+ self . max_field_align < layout. align &&
293
293
layout. align <= mem:: size_of :: < * mut ( ) > ( )
294
- {
295
- let ty = helpers:: blob ( Layout :: new ( 0 , layout. align ) ) ;
296
-
297
- Some ( quote ! {
298
- pub __bindgen_align: #ty ,
299
- } )
300
- } else {
301
- None
302
- }
303
294
}
304
295
305
296
fn padding_bytes ( & self , layout : Layout ) -> usize {
You can’t perform that action at this time.
0 commit comments