Skip to content

Commit 0a1507d

Browse files
committed
Enum and Variant
1 parent f4e3896 commit 0a1507d

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
275275
bounds: ty.bounds.clean(cx),
276276
generics: ty.generics.clean(cx),
277277
})),
278+
ItemKind::Enum(ref def, ref generics) => NotInlined(EnumItem(Enum {
279+
variants: def.variants.iter().map(|v| v.clean(cx)).collect(),
280+
generics: generics.clean(cx),
281+
variants_stripped: false,
282+
})),
278283
ItemKind::Union(ref variant_data, ref generics) => NotInlined(UnionItem(Union {
279284
struct_type: doctree::struct_type_from_def(&variant_data),
280285
generics: generics.clean(cx),
@@ -1917,31 +1922,10 @@ impl Clean<VariantStruct> for rustc_hir::VariantData<'_> {
19171922
}
19181923
}
19191924

1920-
impl Clean<Item> for doctree::Enum<'_> {
1925+
impl Clean<Item> for hir::Variant<'_> {
19211926
fn clean(&self, cx: &DocContext<'_>) -> Item {
1922-
Item::from_hir_id_and_parts(
1923-
self.id,
1924-
Some(self.name),
1925-
EnumItem(Enum {
1926-
variants: self.variants.iter().map(|v| v.clean(cx)).collect(),
1927-
generics: self.generics.clean(cx),
1928-
variants_stripped: false,
1929-
}),
1930-
cx,
1931-
)
1932-
}
1933-
}
1934-
1935-
impl Clean<Item> for doctree::Variant<'_> {
1936-
fn clean(&self, cx: &DocContext<'_>) -> Item {
1937-
let what_rustc_thinks = Item::from_hir_id_and_parts(
1938-
self.id,
1939-
Some(self.name),
1940-
VariantItem(Variant { kind: self.def.clean(cx) }),
1941-
cx,
1942-
);
1943-
// don't show `pub` for variants, which are always public
1944-
Item { visibility: Inherited, ..what_rustc_thinks }
1927+
let kind = VariantItem(Variant { kind: self.data.clean(cx) });
1928+
Item::from_hir_id_and_parts(self.id, Some(self.ident.name), kind, cx)
19451929
}
19461930
}
19471931

src/librustdoc/doctree.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@ crate struct Struct<'hir> {
2626
crate fields: &'hir [hir::StructField<'hir>],
2727
}
2828

29-
crate struct Enum<'hir> {
30-
crate variants: Vec<Variant<'hir>>,
31-
crate generics: &'hir hir::Generics<'hir>,
32-
crate id: hir::HirId,
33-
crate name: Symbol,
34-
}
35-
36-
crate struct Variant<'hir> {
37-
crate name: Symbol,
38-
crate id: hir::HirId,
39-
crate def: &'hir hir::VariantData<'hir>,
40-
}
41-
4229
#[derive(Debug)]
4330
crate struct Static<'hir> {
4431
crate type_: &'hir hir::Ty<'hir>,

0 commit comments

Comments
 (0)