File tree 4 files changed +63
-7
lines changed 4 files changed +63
-7
lines changed Original file line number Diff line number Diff line change @@ -360,8 +360,18 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
360
360
// it's important not to override
361
361
if !args. is_empty ( ) {
362
362
ci. borrow_mut ( ) . args = args;
363
+ // XXX: This is a super-dumb way to get the spesialisation,
364
+ // but it seems to be the only one that'd work here...
365
+ cursor. visit ( |c, _: & Cursor | {
366
+ if c. kind ( ) == CXCursor_TemplateRef {
367
+ let decl = decl_name ( ctx, & c. referenced ( ) ) ;
368
+ ci. borrow_mut ( ) . ref_template = Some ( decl. to_type ( ) ) ;
369
+ }
370
+ CXChildVisit_Continue
371
+ } ) ;
363
372
}
364
373
374
+
365
375
TComp ( ci)
366
376
}
367
377
CXCursor_EnumDecl => {
Original file line number Diff line number Diff line change @@ -538,7 +538,6 @@ impl CompInfo {
538
538
}
539
539
}
540
540
541
- // We only
542
541
pub fn can_derive_copy ( & self ) -> bool {
543
542
match self . kind {
544
543
CompKind :: Union => true ,
@@ -547,12 +546,6 @@ impl CompInfo {
547
546
return false ;
548
547
}
549
548
550
- // Anything not destructible and with template parameters
551
- // is copiable
552
- if self . args . is_empty ( ) {
553
- return true ;
554
- }
555
-
556
549
// With template args, use a safe subset of the types,
557
550
// since copyability depends on the types itself.
558
551
self . ref_template . as_ref ( ) . map_or ( true , |t| t. can_derive_copy ( ) ) &&
Original file line number Diff line number Diff line change @@ -47,6 +47,33 @@ fn bindgen_test_layout_Struct_RootedContainer() {
47
47
assert_eq ! ( :: std:: mem:: size_of:: <Struct_RootedContainer >( ) , 24usize ) ;
48
48
assert_eq ! ( :: std:: mem:: align_of:: <Struct_RootedContainer >( ) , 8usize ) ;
49
49
}
50
+ pub type WithDtorIntFwd = Struct_WithDtor < :: std:: os:: raw:: c_int > ;
51
+ #[ repr( C ) ]
52
+ #[ derive( Debug ) ]
53
+ pub struct Struct_WithDtor < T > {
54
+ pub member : T ,
55
+ }
56
+ #[ repr( C ) ]
57
+ #[ derive( Debug ) ]
58
+ pub struct Struct_PODButContainsDtor {
59
+ pub member : WithDtorIntFwd ,
60
+ }
61
+ #[ test]
62
+ fn bindgen_test_layout_Struct_PODButContainsDtor ( ) {
63
+ assert_eq ! ( :: std:: mem:: size_of:: <Struct_PODButContainsDtor >( ) , 4usize ) ;
64
+ assert_eq ! ( :: std:: mem:: align_of:: <Struct_PODButContainsDtor >( ) , 4usize ) ;
65
+ }
66
+ #[ repr( C ) ]
67
+ pub struct Opaque ;
68
+ #[ repr( C ) ]
69
+ pub struct Struct_POD {
70
+ pub opaque_member : u32 ,
71
+ }
72
+ #[ test]
73
+ fn bindgen_test_layout_Struct_POD ( ) {
74
+ assert_eq ! ( :: std:: mem:: size_of:: <Struct_POD >( ) , 4usize ) ;
75
+ assert_eq ! ( :: std:: mem:: align_of:: <Struct_POD >( ) , 4usize ) ;
76
+ }
50
77
extern "C" {
51
78
#[ link_name = "_Z3bar3FooIiiE" ]
52
79
pub fn bar ( foo : Struct_Foo < :: std:: os:: raw:: c_int , :: std:: os:: raw:: c_int > ) ;
Original file line number Diff line number Diff line change @@ -29,3 +29,29 @@ class Rooted {
29
29
class RootedContainer {
30
30
Rooted<void *> root;
31
31
};
32
+
33
+ template <typename T>
34
+ class WithDtor ;
35
+
36
+ typedef WithDtor<int > WithDtorIntFwd;
37
+
38
+ template <typename T>
39
+ class WithDtor {
40
+ T member;
41
+ ~WithDtor () {}
42
+ };
43
+
44
+ class PODButContainsDtor {
45
+ WithDtorIntFwd member;
46
+ };
47
+
48
+
49
+ /* * <div rustbindgen opaque> */
50
+ template <typename T>
51
+ class Opaque {
52
+ T member;
53
+ };
54
+
55
+ class POD {
56
+ Opaque<int > opaque_member;
57
+ };
You can’t perform that action at this time.
0 commit comments