Skip to content

Commit eaacf59

Browse files
collect impl items from the HIR if available
1 parent ca61286 commit eaacf59

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/librustdoc/clean/inline.rs

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

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

0 commit comments

Comments
 (0)