Skip to content

Commit 341ae70

Browse files
committed
[WIP] fill out Item
1 parent 0b05cee commit 341ae70

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,47 @@ impl Clean<ExternalCrate> for CrateNum {
228228
}
229229
}
230230

231+
/*
232+
impl Clean<ItemEnum> for hir::ItemKind<'_> {
233+
fn clean(&self, _cx: &DocContext<'_>) -> ItemEnum {
234+
match self {
235+
ExternalCrate(name) =>
236+
}
237+
}
238+
}
239+
*/
240+
231241
impl Clean<Item> for hir::Item<'_> {
232-
fn clean(&self, _cx: &DocContext<'_>) -> Item {
233-
unimplemented!()
242+
fn clean(&self, cx: &DocContext<'_>) -> Item {
243+
use hir::ItemKind;
244+
245+
let def_id = cx.tcx.hir().local_def_id(self.hir_id).to_def_id();
246+
let name = cx.tcx.item_name(def_id).clean(cx);
247+
let inner = match self.kind {
248+
// TODO: should store Symbol, not String
249+
ItemKind::ExternCrate(renamed) => ExternCrateItem(name.clone(), renamed.clean(cx)),
250+
ItemKind::Use(path, kind) => {
251+
unimplemented!()
252+
}
253+
/*
254+
ImportItem(Import {
255+
kind: kind.clean(cx),
256+
source: path.clean(cx),
257+
}),
258+
*/
259+
_ => unimplemented!(),
260+
};
261+
262+
Item {
263+
def_id,
264+
inner,
265+
name: Some(name),
266+
source: cx.tcx.def_span(def_id).clean(cx),
267+
attrs: self.attrs.clean(cx), // should this use tcx.attrs instead?
268+
visibility: self.vis.clean(cx), // TODO: use tcx.visibility once #78077 lands
269+
stability: cx.tcx.lookup_stability(def_id).copied(),
270+
deprecation: cx.tcx.lookup_deprecation(def_id).clean(cx),
271+
}
234272
}
235273
}
236274

0 commit comments

Comments
 (0)