diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen/mod.rs | 8 | ||||
-rw-r--r-- | src/ir/comp.rs | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index ad4f65f4..49187125 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1559,7 +1559,7 @@ impl CodeGenerator for CompInfo { struct_layout.saw_vtable(); } - for (i, base) in self.base_members().iter().enumerate() { + for base in self.base_members() { // Virtual bases are already taken into account by the vtable // pointer. // @@ -1577,11 +1577,7 @@ impl CodeGenerator for CompInfo { } let inner = base.ty.to_rust_ty_or_opaque(ctx, &()); - let field_name = ctx.rust_ident(if i == 0 { - "_base".into() - } else { - format!("_base_{}", i) - }); + let field_name = ctx.rust_ident(&base.field_name); struct_layout.saw_base(base_ty); diff --git a/src/ir/comp.rs b/src/ir/comp.rs index bbccd06a..4c57a86b 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -769,6 +769,8 @@ pub struct Base { pub ty: ItemId, /// The kind of inheritance we're doing. pub kind: BaseKind, + /// Name of the field in which this base should be stored. + pub field_name: String, } impl Base { @@ -1155,11 +1157,16 @@ impl CompInfo { BaseKind::Normal }; + let field_name = match ci.base_members.len() { + 0 => "_base".into(), + n => format!("_base_{}", n), + }; let type_id = Item::from_ty_or_ref(cur.cur_type(), cur, None, ctx); ci.base_members.push(Base { ty: type_id, kind: kind, + field_name: field_name, }); } CXCursor_Constructor | |