Allow inheritance between structs.

No subtyping, no interaction with traits. Partially addresses #9912.
This commit is contained in:
Nick Cameron
2014-02-24 20:17:02 +13:00
parent 3757f01c9b
commit ff04aa8e38
30 changed files with 800 additions and 205 deletions

View File

@@ -640,6 +640,9 @@ impl<'a> State<'a> {
));
}
ast::ItemStruct(struct_def, ref generics) => {
if struct_def.is_virtual {
try!(self.word_space("virtual"));
}
try!(self.head(visibility_qualified(item.vis, "struct")));
try!(self.print_struct(struct_def, generics, item.ident, item.span));
}
@@ -754,6 +757,13 @@ impl<'a> State<'a> {
span: codemap::Span) -> IoResult<()> {
try!(self.print_ident(ident));
try!(self.print_generics(generics));
match struct_def.super_struct {
Some(t) => {
try!(self.word_space(":"));
try!(self.print_type(t));
},
None => {},
}
if ast_util::struct_def_is_tuple_like(struct_def) {
if !struct_def.fields.is_empty() {
try!(self.popen());