File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -835,14 +835,18 @@ impl CodeGenerator for CompInfo {
835
835
}
836
836
837
837
for ( i, base) in self . base_members ( ) . iter ( ) . enumerate ( ) {
838
+ // Virtual bases are already taken into account by the vtable
839
+ // pointer.
840
+ //
841
+ // FIXME(emilio): Is this always right?
842
+ if base. is_virtual ( ) {
843
+ continue ;
844
+ }
845
+
838
846
let base_ty = ctx. resolve_type ( base. ty ) ;
839
847
// NB: We won't include unsized types in our base chain because they
840
848
// would contribute to our size given the dummy field we insert for
841
849
// unsized types.
842
- //
843
- // NB: Canonical type is here because it could be inheriting from a
844
- // typedef, for example, and the lack of `unwrap()` is because we
845
- // can inherit from a template parameter, yes.
846
850
if base_ty. is_unsized ( ctx) {
847
851
continue ;
848
852
}
Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ impl<'a> CanDeriveCopy<'a> for Field {
176
176
177
177
178
178
/// The kind of inheritance a base class is using.
179
- #[ derive( Clone , Debug ) ]
179
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
180
180
pub enum BaseKind {
181
181
/// Normal inheritance, like:
182
182
///
@@ -201,6 +201,13 @@ pub struct Base {
201
201
pub kind : BaseKind ,
202
202
}
203
203
204
+ impl Base {
205
+ /// Whether this base class is inheriting virtually.
206
+ pub fn is_virtual ( & self ) -> bool {
207
+ self . kind == BaseKind :: Virtual
208
+ }
209
+ }
210
+
204
211
/// A compound type.
205
212
///
206
213
/// Either a struct or union, a compound type is built up from the combination
You can’t perform that action at this time.
0 commit comments