Skip to content

Commit 5ba37bc

Browse files
committed
[WIP] add ConstantItem
1 parent 350e4d7 commit 5ba37bc

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
250250
mutability,
251251
expr: print_const_expr(cx, body_id),
252252
})),
253-
ItemKind::Const(ty, body_id) => unimplemented!(),
253+
ItemKind::Const(ty, body_id) => NotInlined(ConstantItem(Constant {
254+
type_: ty.clean(cx),
255+
expr: print_const_expr(cx, body_id),
256+
value: print_evaluated_const(cx, def_id),
257+
is_literal: is_literal_expr(cx, body_id.hir_id),
258+
})),
254259
ItemKind::Union(ref variant_data, ref generics) => NotInlined(UnionItem(Union {
255260
struct_type: doctree::struct_type_from_def(&variant_data),
256261
generics: generics.clean(cx),
@@ -2070,24 +2075,6 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
20702075
}
20712076
}
20722077

2073-
impl Clean<Item> for doctree::Constant<'_> {
2074-
fn clean(&self, cx: &DocContext<'_>) -> Item {
2075-
let def_id = cx.tcx.hir().local_def_id(self.id).to_def_id();
2076-
2077-
Item::from_def_id_and_parts(
2078-
def_id,
2079-
Some(self.name),
2080-
ConstantItem(Constant {
2081-
type_: self.type_.clean(cx),
2082-
expr: print_const_expr(cx, self.expr),
2083-
value: print_evaluated_const(cx, def_id),
2084-
is_literal: is_literal_expr(cx, self.expr.hir_id),
2085-
}),
2086-
cx,
2087-
)
2088-
}
2089-
}
2090-
20912078
impl Clean<ImplPolarity> for ty::ImplPolarity {
20922079
fn clean(&self, _: &DocContext<'_>) -> ImplPolarity {
20932080
match self {

src/librustdoc/doctree.rs

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

29-
crate struct Union<'hir> {
30-
crate id: hir::HirId,
31-
crate struct_type: StructType,
32-
crate name: Symbol,
33-
crate generics: &'hir hir::Generics<'hir>,
34-
crate fields: &'hir [hir::StructField<'hir>],
35-
}
36-
3729
crate struct Enum<'hir> {
3830
crate variants: Vec<Variant<'hir>>,
3931
crate generics: &'hir hir::Generics<'hir>,
@@ -81,13 +73,6 @@ crate struct Static<'hir> {
8173
crate span: Span,
8274
}
8375

84-
crate struct Constant<'hir> {
85-
crate type_: &'hir hir::Ty<'hir>,
86-
crate expr: hir::BodyId,
87-
crate name: Symbol,
88-
crate id: hir::HirId,
89-
}
90-
9176
crate struct Trait<'hir> {
9277
crate is_auto: hir::IsAuto,
9378
crate unsafety: hir::Unsafety,

0 commit comments

Comments
 (0)