summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-03-21 06:48:04 -0700
committerGitHub <noreply@github.com>2017-03-21 06:48:04 -0700
commitb4e3be9d25c583cb24a4b4d4587f292170c25b0d (patch)
treeb38b64cefc739a1ab0547727016cb9ebc948afc1 /src/codegen/mod.rs
parentcc6f3b251a495ca68aaad4eb49d5469898bbbe80 (diff)
parentf67967a2930082ef54cde03d26dc3c0fe8f388cd (diff)
Auto merge of #597 - servo:void-vtable, r=fitzgen,emilio
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 ``` Emilio said on IRC: > the empty vtable means that we don't care of figuring out the proper vtable layout, so we create an empty struct Sounds like all that matters is to have a pointer, we don’t look at the data behind it. Using `c_void` seems appropriate, then.
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 7db083e7..fb6c839d 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -706,17 +706,15 @@ impl<'a> CodeGenerator for Vtable<'a> {
assert_eq!(item.id(), self.item_id);
// For now, generate an empty struct, later we should generate function
// pointers and whatnot.
- let mut attributes = vec![attributes::repr("C")];
-
- if ctx.options().derive_default {
- attributes.push(attributes::derives(&["Default"]))
- }
+ let attributes = vec![attributes::repr("C")];
let vtable = aster::AstBuilder::new()
.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);
}