summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-03-20 18:35:13 +0100
committerSimon Sapin <simon.sapin@exyr.org>2017-03-21 14:46:46 +0100
commitf67967a2930082ef54cde03d26dc3c0fe8f388cd (patch)
treeb38b64cefc739a1ab0547727016cb9ebc948afc1
parent1abd864972012b2c027fc3378f1db88333f5d6ea (diff)
Make vtables non-zero-size to fix a rustc warning.
``` warning: found non-foreign-function-safe member in struct marked #[repr(C)]: found zero-size struct in foreign module, consider adding a member to this struct ```
-rw-r--r--src/codegen/mod.rs4
-rw-r--r--tests/expectations/tests/enum_and_vtable_mangling.rs3
-rw-r--r--tests/expectations/tests/nested_vtable.rs3
-rw-r--r--tests/expectations/tests/ref_argument_array.rs3
-rw-r--r--tests/expectations/tests/virtual_dtor.rs3
-rw-r--r--tests/expectations/tests/virtual_inheritance.rs6
-rw-r--r--tests/expectations/tests/virtual_overloaded.rs3
-rw-r--r--tests/expectations/tests/vtable_recursive_sig.rs3
8 files changed, 11 insertions, 17 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 577b8aab..fb6c839d 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -712,7 +712,9 @@ impl<'a> CodeGenerator for Vtable<'a> {
.item()
.pub_()
.with_attrs(attributes)
- .struct_(self.canonical_name(ctx))
+ .tuple_struct(self.canonical_name(ctx))
+ .field()
+ .build_ty(helpers::ast_ty::raw_type(ctx, "c_void"))
.build();
result.push(vtable);
}
diff --git a/tests/expectations/tests/enum_and_vtable_mangling.rs b/tests/expectations/tests/enum_and_vtable_mangling.rs
index f1a58093..b34e217f 100644
--- a/tests/expectations/tests/enum_and_vtable_mangling.rs
+++ b/tests/expectations/tests/enum_and_vtable_mangling.rs
@@ -10,8 +10,7 @@ pub const whatever_else: _bindgen_ty_1 = _bindgen_ty_1::whatever_else;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_1 { match_ = 0, whatever_else = 1, }
#[repr(C)]
-pub struct C__bindgen_vtable {
-}
+pub struct C__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct C {
diff --git a/tests/expectations/tests/nested_vtable.rs b/tests/expectations/tests/nested_vtable.rs
index 62466ee0..4c9dc8f6 100644
--- a/tests/expectations/tests/nested_vtable.rs
+++ b/tests/expectations/tests/nested_vtable.rs
@@ -5,8 +5,7 @@
#[repr(C)]
-pub struct nsISupports__bindgen_vtable {
-}
+pub struct nsISupports__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct nsISupports {
diff --git a/tests/expectations/tests/ref_argument_array.rs b/tests/expectations/tests/ref_argument_array.rs
index ac761796..51531824 100644
--- a/tests/expectations/tests/ref_argument_array.rs
+++ b/tests/expectations/tests/ref_argument_array.rs
@@ -6,8 +6,7 @@
pub const NSID_LENGTH: ::std::os::raw::c_uint = 10;
#[repr(C)]
-pub struct nsID__bindgen_vtable {
-}
+pub struct nsID__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct nsID {
diff --git a/tests/expectations/tests/virtual_dtor.rs b/tests/expectations/tests/virtual_dtor.rs
index 9df3c31c..e5d3ace2 100644
--- a/tests/expectations/tests/virtual_dtor.rs
+++ b/tests/expectations/tests/virtual_dtor.rs
@@ -5,8 +5,7 @@
#[repr(C)]
-pub struct nsSlots__bindgen_vtable {
-}
+pub struct nsSlots__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug)]
pub struct nsSlots {
diff --git a/tests/expectations/tests/virtual_inheritance.rs b/tests/expectations/tests/virtual_inheritance.rs
index a09ad567..b3119ca7 100644
--- a/tests/expectations/tests/virtual_inheritance.rs
+++ b/tests/expectations/tests/virtual_inheritance.rs
@@ -25,8 +25,7 @@ impl Clone for A {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-pub struct B__bindgen_vtable {
-}
+pub struct B__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct B {
@@ -52,8 +51,7 @@ impl Default for B {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-pub struct C__bindgen_vtable {
-}
+pub struct C__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct C {
diff --git a/tests/expectations/tests/virtual_overloaded.rs b/tests/expectations/tests/virtual_overloaded.rs
index b10d2adc..625abe3b 100644
--- a/tests/expectations/tests/virtual_overloaded.rs
+++ b/tests/expectations/tests/virtual_overloaded.rs
@@ -5,8 +5,7 @@
#[repr(C)]
-pub struct C__bindgen_vtable {
-}
+pub struct C__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct C {
diff --git a/tests/expectations/tests/vtable_recursive_sig.rs b/tests/expectations/tests/vtable_recursive_sig.rs
index 18e4f07e..0faf37ac 100644
--- a/tests/expectations/tests/vtable_recursive_sig.rs
+++ b/tests/expectations/tests/vtable_recursive_sig.rs
@@ -23,8 +23,7 @@ impl Default for Derived {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-pub struct Base__bindgen_vtable {
-}
+pub struct Base__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Base {