Skip to content

Commit 2d88dd1

Browse files
author
bors-servo
authored
Auto merge of rust-lang#692 - emilio:virtual-template-params, r=fitzgen
ir: Don't assume template instantiation argument with vtable implies vtable Fixes rust-lang#691
2 parents 12f9852 + b40f9f0 commit 2d88dd1

File tree

5 files changed

+75
-4
lines changed

5 files changed

+75
-4
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ name = "bindgen"
1313
readme = "README.md"
1414
repository = "https://github.com/servo/rust-bindgen"
1515
documentation = "https://docs.rs/bindgen"
16-
version = "0.24.0"
16+
version = "0.24.1"
1717
build = "build.rs"
1818

1919
exclude = [

src/ir/template.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ impl TemplateInstantiation {
279279

280280
/// Does this instantiation have a vtable?
281281
pub fn has_vtable(&self, ctx: &BindgenContext) -> bool {
282-
ctx.resolve_type(self.definition).has_vtable(ctx) ||
283-
self.args.iter().any(|arg| ctx.resolve_type(*arg).has_vtable(ctx))
282+
ctx.resolve_type(self.definition).has_vtable(ctx)
284283
}
285284

286285
/// Does this instantiation have a destructor?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
pub struct VirtualMethods__bindgen_vtable(::std::os::raw::c_void);
9+
#[repr(C)]
10+
#[derive(Debug, Copy)]
11+
pub struct VirtualMethods {
12+
pub vtable_: *const VirtualMethods__bindgen_vtable,
13+
}
14+
#[test]
15+
fn bindgen_test_layout_VirtualMethods() {
16+
assert_eq!(::std::mem::size_of::<VirtualMethods>() , 8usize , concat ! (
17+
"Size of: " , stringify ! ( VirtualMethods ) ));
18+
assert_eq! (::std::mem::align_of::<VirtualMethods>() , 8usize , concat ! (
19+
"Alignment of " , stringify ! ( VirtualMethods ) ));
20+
}
21+
impl Clone for VirtualMethods {
22+
fn clone(&self) -> Self { *self }
23+
}
24+
impl Default for VirtualMethods {
25+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
26+
}
27+
#[repr(C)]
28+
#[derive(Debug, Default, Copy, Clone)]
29+
pub struct Set {
30+
pub bar: ::std::os::raw::c_int,
31+
}
32+
#[repr(C)]
33+
#[derive(Debug, Copy)]
34+
pub struct ServoElementSnapshotTable {
35+
pub _base: Set,
36+
}
37+
#[test]
38+
fn bindgen_test_layout_ServoElementSnapshotTable() {
39+
assert_eq!(::std::mem::size_of::<ServoElementSnapshotTable>() , 4usize ,
40+
concat ! (
41+
"Size of: " , stringify ! ( ServoElementSnapshotTable ) ));
42+
assert_eq! (::std::mem::align_of::<ServoElementSnapshotTable>() , 4usize ,
43+
concat ! (
44+
"Alignment of " , stringify ! ( ServoElementSnapshotTable )
45+
));
46+
}
47+
impl Clone for ServoElementSnapshotTable {
48+
fn clone(&self) -> Self { *self }
49+
}
50+
impl Default for ServoElementSnapshotTable {
51+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
52+
}
53+
#[test]
54+
fn __bindgen_test_layout_Set_instantiation_13() {
55+
assert_eq!(::std::mem::size_of::<Set>() , 4usize , concat ! (
56+
"Size of template specialization: " , stringify ! ( Set ) ));
57+
assert_eq!(::std::mem::align_of::<Set>() , 4usize , concat ! (
58+
"Alignment of template specialization: " , stringify ! ( Set )
59+
));
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class VirtualMethods {
2+
virtual void foo();
3+
};
4+
5+
template<typename K>
6+
class Set {
7+
int bar;
8+
};
9+
10+
class ServoElementSnapshotTable
11+
: public Set<VirtualMethods>
12+
{};

0 commit comments

Comments
 (0)