Skip to content

Commit 42d4dbb

Browse files
committed
[WIP] ModuleItem
1 parent bd38b65 commit 42d4dbb

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
256256
value: print_evaluated_const(cx, def_id),
257257
is_literal: is_literal_expr(cx, body_id.hir_id),
258258
})),
259-
ItemKind::Fn(ref sig, ref generics, body) => NotInlined(clean_function(self, sig, &generics, body, cx)),
259+
ItemKind::Fn(ref sig, ref generics, body) => {
260+
NotInlined(clean_function(self, sig, &generics, body, cx))
261+
}
262+
// TODO: this should also take the span into account (inner or outer)
263+
ItemKind::Mod(ref mod_) => NotInlined(mod_.clean(cx)),
260264
ItemKind::Union(ref variant_data, ref generics) => NotInlined(UnionItem(Union {
261265
struct_type: doctree::struct_type_from_def(&variant_data),
262266
generics: generics.clean(cx),
@@ -347,6 +351,21 @@ impl Clean<Item> for hir::Crate<'_> {
347351
}
348352
}
349353

354+
impl Clean<ItemKind> for hir::Mod<'_> {
355+
fn clean(&self, cx: &DocContext<'_>) -> ItemKind {
356+
ModuleItem(Module {
357+
is_crate: false,
358+
items: self.item_ids.clean(cx).into_iter().flatten().collect(),
359+
})
360+
}
361+
}
362+
363+
impl Clean<Vec<Item>> for hir::ItemId {
364+
fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
365+
cx.tcx.hir().item(self.id).clean(cx)
366+
}
367+
}
368+
350369
impl Clean<Vec<Item>> for hir::ModuleItems {
351370
fn clean(&self, _cx: &DocContext<'_>) -> Vec<Item> {
352371
unimplemented!()
@@ -963,7 +982,13 @@ impl<'a> Clean<Function> for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::Bo
963982
}
964983
}
965984

966-
fn clean_function(item: &hir::Item<'_>, sig: &hir::FnSig<'_>, generics: &hir::Generics<'_>, body: hir::BodyId, cx: &DocContext<'_>) -> ItemKind {
985+
fn clean_function(
986+
item: &hir::Item<'_>,
987+
sig: &hir::FnSig<'_>,
988+
generics: &hir::Generics<'_>,
989+
body: hir::BodyId,
990+
cx: &DocContext<'_>,
991+
) -> ItemKind {
967992
let (generics, decl) =
968993
enter_impl_trait(cx, || (generics.clean(cx), (sig.decl, body).clean(cx)));
969994

0 commit comments

Comments
 (0)