diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-08 16:05:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-08 16:05:59 -0500 |
commit | 2d88dd106bf33807679f531051546f3c9889161e (patch) | |
tree | 3cb767e01cf8644a4b58b944b47c2a6eff79daf6 | |
parent | 12f985283f30dc9867d0b608f2bbf3007f0898b3 (diff) | |
parent | b40f9f06dc543afaaba0fee60fb5c4feb2f3ecf0 (diff) |
Auto merge of #692 - emilio:virtual-template-params, r=fitzgenv0.24.1
ir: Don't assume template instantiation argument with vtable implies vtable
Fixes #691
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/ir/template.rs | 3 | ||||
-rw-r--r-- | tests/expectations/tests/issue-691-template-parameter-virtual.rs | 60 | ||||
-rw-r--r-- | tests/headers/issue-691-template-parameter-virtual.hpp | 12 |
5 files changed, 75 insertions, 4 deletions
@@ -1,6 +1,6 @@ [root] name = "bindgen" -version = "0.24.0" +version = "0.24.1" dependencies = [ "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -13,7 +13,7 @@ name = "bindgen" readme = "README.md" repository = "https://github.com/servo/rust-bindgen" documentation = "https://docs.rs/bindgen" -version = "0.24.0" +version = "0.24.1" build = "build.rs" exclude = [ diff --git a/src/ir/template.rs b/src/ir/template.rs index d2996330..5861929f 100644 --- a/src/ir/template.rs +++ b/src/ir/template.rs @@ -279,8 +279,7 @@ impl TemplateInstantiation { /// Does this instantiation have a vtable? pub fn has_vtable(&self, ctx: &BindgenContext) -> bool { - ctx.resolve_type(self.definition).has_vtable(ctx) || - self.args.iter().any(|arg| ctx.resolve_type(*arg).has_vtable(ctx)) + ctx.resolve_type(self.definition).has_vtable(ctx) } /// Does this instantiation have a destructor? diff --git a/tests/expectations/tests/issue-691-template-parameter-virtual.rs b/tests/expectations/tests/issue-691-template-parameter-virtual.rs new file mode 100644 index 00000000..8333f1f7 --- /dev/null +++ b/tests/expectations/tests/issue-691-template-parameter-virtual.rs @@ -0,0 +1,60 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +pub struct VirtualMethods__bindgen_vtable(::std::os::raw::c_void); +#[repr(C)] +#[derive(Debug, Copy)] +pub struct VirtualMethods { + pub vtable_: *const VirtualMethods__bindgen_vtable, +} +#[test] +fn bindgen_test_layout_VirtualMethods() { + assert_eq!(::std::mem::size_of::<VirtualMethods>() , 8usize , concat ! ( + "Size of: " , stringify ! ( VirtualMethods ) )); + assert_eq! (::std::mem::align_of::<VirtualMethods>() , 8usize , concat ! ( + "Alignment of " , stringify ! ( VirtualMethods ) )); +} +impl Clone for VirtualMethods { + fn clone(&self) -> Self { *self } +} +impl Default for VirtualMethods { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Set { + pub bar: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ServoElementSnapshotTable { + pub _base: Set, +} +#[test] +fn bindgen_test_layout_ServoElementSnapshotTable() { + assert_eq!(::std::mem::size_of::<ServoElementSnapshotTable>() , 4usize , + concat ! ( + "Size of: " , stringify ! ( ServoElementSnapshotTable ) )); + assert_eq! (::std::mem::align_of::<ServoElementSnapshotTable>() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( ServoElementSnapshotTable ) + )); +} +impl Clone for ServoElementSnapshotTable { + fn clone(&self) -> Self { *self } +} +impl Default for ServoElementSnapshotTable { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[test] +fn __bindgen_test_layout_Set_instantiation_13() { + assert_eq!(::std::mem::size_of::<Set>() , 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( Set ) )); + assert_eq!(::std::mem::align_of::<Set>() , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( Set ) + )); +} diff --git a/tests/headers/issue-691-template-parameter-virtual.hpp b/tests/headers/issue-691-template-parameter-virtual.hpp new file mode 100644 index 00000000..f80e058d --- /dev/null +++ b/tests/headers/issue-691-template-parameter-virtual.hpp @@ -0,0 +1,12 @@ +class VirtualMethods { + virtual void foo(); +}; + +template<typename K> +class Set { + int bar; +}; + +class ServoElementSnapshotTable + : public Set<VirtualMethods> +{}; |