Skip to content

Commit fe26efe

Browse files
collect impl items from the HIR if available
1 parent 978c13a commit fe26efe

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/librustdoc/clean/inline.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,24 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
335335
}
336336

337337
let predicates = tcx.predicates_of(did);
338-
let trait_items = tcx.associated_items(did).filter_map(|item| {
339-
if associated_trait.is_some() || item.vis == ty::Visibility::Public {
340-
Some(item.clean(cx))
341-
} else {
342-
None
338+
let trait_items = if let Some(nodeid) = tcx.hir.as_local_node_id(did) {
339+
match tcx.hir.expect_item(nodeid).node {
340+
hir::ItemKind::Impl(.., ref item_ids) => {
341+
item_ids.iter()
342+
.map(|ii| tcx.hir.impl_item(ii.id).clean(cx))
343+
.collect::<Vec<_>>()
344+
}
345+
_ => panic!("did given to build_impl was not an impl"),
343346
}
344-
}).collect::<Vec<_>>();
347+
} else {
348+
tcx.associated_items(did).filter_map(|item| {
349+
if associated_trait.is_some() || item.vis == ty::Visibility::Public {
350+
Some(item.clean(cx))
351+
} else {
352+
None
353+
}
354+
}).collect::<Vec<_>>()
355+
};
345356
let polarity = tcx.impl_polarity(did);
346357
let trait_ = associated_trait.clean(cx).map(|bound| {
347358
match bound {

0 commit comments

Comments
 (0)