diff options
-rw-r--r-- | src/codegen/mod.rs | 4 | ||||
-rw-r--r-- | src/ir/comp.rs | 4 | ||||
-rw-r--r-- | src/ir/context.rs | 2 | ||||
-rw-r--r-- | src/ir/item.rs | 8 | ||||
-rw-r--r-- | src/ir/ty.rs | 3 |
5 files changed, 12 insertions, 9 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index ce5054c9..264b701b 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1626,7 +1626,7 @@ impl CodeGenerator for CompInfo { warn!("Opaque type without layout! Expect dragons!"); } } - } else if !is_union && !self.is_unsized(ctx, item.id()) { + } else if !is_union && !self.is_unsized(ctx, item.id().expect_type_id(ctx)) { if let Some(padding_field) = layout.and_then(|layout| struct_layout.pad_struct(layout)) { @@ -1650,7 +1650,7 @@ impl CodeGenerator for CompInfo { // // NOTE: This check is conveniently here to avoid the dummy fields we // may add for unused template parameters. - if self.is_unsized(ctx, item.id()) { + if self.is_unsized(ctx, item.id().expect_type_id(ctx)) { let has_address = if is_opaque { // Generate the address field if it's an opaque type and // couldn't determine the layout of the blob. diff --git a/src/ir/comp.rs b/src/ir/comp.rs index fa137068..caa02243 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -911,8 +911,8 @@ impl CompInfo { } /// Is this compound type unsized? - pub fn is_unsized<Id: Into<ItemId>>(&self, ctx: &BindgenContext, id: Id) -> bool { - !ctx.lookup_item_id_has_vtable(id.into()) && self.fields().is_empty() && + pub fn is_unsized(&self, ctx: &BindgenContext, id: TypeId) -> bool { + !ctx.lookup_item_id_has_vtable(id) && self.fields().is_empty() && self.base_members.iter().all(|base| { ctx.resolve_type(base.ty).canonical_type(ctx).is_unsized( ctx, diff --git a/src/ir/context.rs b/src/ir/context.rs index 3dfef1de..1c85e738 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -1253,7 +1253,7 @@ impl BindgenContext { } /// Look up whether the item with `id` has vtable or not. - pub fn lookup_item_id_has_vtable<Id: Into<ItemId>>(&self, id: Id) -> bool { + pub fn lookup_item_id_has_vtable(&self, id: TypeId) -> bool { assert!( self.in_codegen_phase(), "We only compute vtables when we enter codegen" diff --git a/src/ir/item.rs b/src/ir/item.rs index 3a4c49d4..31d42080 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -999,13 +999,17 @@ where T: Copy + Into<ItemId> { fn has_vtable(&self, ctx: &BindgenContext) -> bool { - ctx.lookup_item_id_has_vtable(*self) + let id: ItemId = (*self).into(); + id.as_type_id(ctx) + .map_or(false, |id| ctx.lookup_item_id_has_vtable(id)) } } impl HasVtable for Item { fn has_vtable(&self, ctx: &BindgenContext) -> bool { - ctx.lookup_item_id_has_vtable(self.id()) + self.id() + .as_type_id(ctx) + .map_or(false, |id| ctx.lookup_item_id_has_vtable(id)) } } diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 5aef39a2..45555344 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -693,10 +693,9 @@ impl Type { /// derive whether we should generate a dummy `_address` field for structs, /// to comply to the C and C++ layouts, that specify that every type needs /// to be addressable. - pub fn is_unsized<Id: Into<ItemId>>(&self, ctx: &BindgenContext, id: Id) -> bool { + pub fn is_unsized(&self, ctx: &BindgenContext, id: TypeId) -> bool { debug_assert!(ctx.in_codegen_phase(), "Not yet"); - let id = id.into(); match self.kind { TypeKind::Void => true, TypeKind::Comp(ref ci) => ci.is_unsized(ctx, id), |