Merge struct fields and struct kind
This commit is contained in:
parent
30af54dede
commit
40aa09e4c9
36 changed files with 222 additions and 148 deletions
|
|
@ -1809,7 +1809,7 @@ impl Clean<VariantStruct> for ::rustc_front::hir::VariantData {
|
|||
fn clean(&self, cx: &DocContext) -> VariantStruct {
|
||||
VariantStruct {
|
||||
struct_type: doctree::struct_type_from_def(self),
|
||||
fields: self.fields.clean(cx),
|
||||
fields: self.fields().map(|x| x.clean(cx)).collect(),
|
||||
fields_stripped: false,
|
||||
}
|
||||
}
|
||||
|
|
@ -1918,12 +1918,12 @@ pub enum VariantKind {
|
|||
}
|
||||
|
||||
fn struct_def_to_variant_kind(struct_def: &hir::VariantData, cx: &DocContext) -> VariantKind {
|
||||
if struct_def.kind == hir::VariantKind::Struct {
|
||||
if struct_def.is_struct() {
|
||||
StructVariant(struct_def.clean(cx))
|
||||
} else if struct_def.kind == hir::VariantKind::Unit {
|
||||
} else if struct_def.is_unit() {
|
||||
CLikeVariant
|
||||
} else {
|
||||
TupleVariant(struct_def.fields.iter().map(|x| x.node.ty.clean(cx)).collect())
|
||||
TupleVariant(struct_def.fields().map(|x| x.node.ty.clean(cx)).collect())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -234,9 +234,9 @@ pub struct Import {
|
|||
}
|
||||
|
||||
pub fn struct_type_from_def(sd: &hir::VariantData) -> StructType {
|
||||
if sd.kind != hir::VariantKind::Struct {
|
||||
if !sd.is_struct() {
|
||||
// We are in a tuple-struct
|
||||
match sd.fields.len() {
|
||||
match sd.fields().count() {
|
||||
0 => Unit,
|
||||
1 => Newtype,
|
||||
_ => Tuple
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
stab: self.stability(item.id),
|
||||
attrs: item.attrs.clone(),
|
||||
generics: generics.clone(),
|
||||
fields: sd.fields.clone(),
|
||||
fields: sd.fields().cloned().collect(),
|
||||
whence: item.span
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue