mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Remove Clean trait implementation for ty::VariantDef
This commit is contained in:
parent
c907b6f7e0
commit
21c812aa7a
@ -17,8 +17,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
|||||||
|
|
||||||
use crate::clean::{
|
use crate::clean::{
|
||||||
self, clean_fn_decl_from_did_and_sig, clean_middle_field, clean_middle_ty, clean_ty,
|
self, clean_fn_decl_from_did_and_sig, clean_middle_field, clean_middle_ty, clean_ty,
|
||||||
clean_ty_generics, clean_visibility, utils, Attributes, AttributesExt, Clean, ImplKind, ItemId,
|
clean_ty_generics, clean_variant_def, clean_visibility, utils, Attributes, AttributesExt,
|
||||||
Type, Visibility,
|
Clean, ImplKind, ItemId, Type, Visibility,
|
||||||
};
|
};
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::formats::item_type::ItemType;
|
use crate::formats::item_type::ItemType;
|
||||||
@ -236,7 +236,7 @@ fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum {
|
|||||||
|
|
||||||
clean::Enum {
|
clean::Enum {
|
||||||
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
|
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
|
||||||
variants: cx.tcx.adt_def(did).variants().iter().map(|v| v.clean(cx)).collect(),
|
variants: cx.tcx.adt_def(did).variants().iter().map(|v| clean_variant_def(v, cx)).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1834,23 +1834,21 @@ fn clean_variant_data<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Clean<'tcx, Item> for ty::VariantDef {
|
pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocContext<'tcx>) -> Item {
|
||||||
fn clean(&self, cx: &mut DocContext<'tcx>) -> Item {
|
let kind = match variant.ctor_kind {
|
||||||
let kind = match self.ctor_kind {
|
CtorKind::Const => Variant::CLike,
|
||||||
CtorKind::Const => Variant::CLike,
|
CtorKind::Fn => Variant::Tuple(
|
||||||
CtorKind::Fn => Variant::Tuple(
|
variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
|
||||||
self.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
|
),
|
||||||
),
|
CtorKind::Fictive => Variant::Struct(VariantStruct {
|
||||||
CtorKind::Fictive => Variant::Struct(VariantStruct {
|
struct_type: CtorKind::Fictive,
|
||||||
struct_type: CtorKind::Fictive,
|
fields: variant.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
|
||||||
fields: self.fields.iter().map(|field| clean_middle_field(field, cx)).collect(),
|
}),
|
||||||
}),
|
};
|
||||||
};
|
let what_rustc_thinks =
|
||||||
let what_rustc_thinks =
|
Item::from_def_id_and_parts(variant.def_id, Some(variant.name), VariantItem(kind), cx);
|
||||||
Item::from_def_id_and_parts(self.def_id, Some(self.name), VariantItem(kind), cx);
|
// don't show `pub` for variants, which always inherit visibility
|
||||||
// don't show `pub` for variants, which always inherit visibility
|
Item { visibility: Inherited, ..what_rustc_thinks }
|
||||||
Item { visibility: Inherited, ..what_rustc_thinks }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> {
|
impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> {
|
||||||
|
Loading…
Reference in New Issue
Block a user