Skip to content

Commit becdc79

Browse files
author
bors-servo
authored
Auto merge of #1014 - pepyakin:generate-base-names, r=fitzgen
Generate base names upon construction As per #1012 (comment) r? @fitzgen
2 parents 30d6e04 + 24c2037 commit becdc79

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/codegen/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ impl CodeGenerator for CompInfo {
15591559
struct_layout.saw_vtable();
15601560
}
15611561

1562-
for (i, base) in self.base_members().iter().enumerate() {
1562+
for base in self.base_members() {
15631563
// Virtual bases are already taken into account by the vtable
15641564
// pointer.
15651565
//
@@ -1577,11 +1577,7 @@ impl CodeGenerator for CompInfo {
15771577
}
15781578

15791579
let inner = base.ty.to_rust_ty_or_opaque(ctx, &());
1580-
let field_name = ctx.rust_ident(if i == 0 {
1581-
"_base".into()
1582-
} else {
1583-
format!("_base_{}", i)
1584-
});
1580+
let field_name = ctx.rust_ident(&base.field_name);
15851581

15861582
struct_layout.saw_base(base_ty);
15871583

src/ir/comp.rs

+7
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ pub struct Base {
769769
pub ty: ItemId,
770770
/// The kind of inheritance we're doing.
771771
pub kind: BaseKind,
772+
/// Name of the field in which this base should be stored.
773+
pub field_name: String,
772774
}
773775

774776
impl Base {
@@ -1155,11 +1157,16 @@ impl CompInfo {
11551157
BaseKind::Normal
11561158
};
11571159

1160+
let field_name = match ci.base_members.len() {
1161+
0 => "_base".into(),
1162+
n => format!("_base_{}", n),
1163+
};
11581164
let type_id =
11591165
Item::from_ty_or_ref(cur.cur_type(), cur, None, ctx);
11601166
ci.base_members.push(Base {
11611167
ty: type_id,
11621168
kind: kind,
1169+
field_name: field_name,
11631170
});
11641171
}
11651172
CXCursor_Constructor |

0 commit comments

Comments
 (0)