Skip to content

Commit

Permalink
pull impl generics from HIR if available
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietMisdreavus committed Sep 20, 2018
1 parent fe26efe commit de6a897
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/librustdoc/clean/inline.rs
Expand Up @@ -335,23 +335,29 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
}

let predicates = tcx.predicates_of(did);
let trait_items = if let Some(nodeid) = tcx.hir.as_local_node_id(did) {
let (trait_items, generics) = if let Some(nodeid) = tcx.hir.as_local_node_id(did) {
match tcx.hir.expect_item(nodeid).node {
hir::ItemKind::Impl(.., ref item_ids) => {
item_ids.iter()
.map(|ii| tcx.hir.impl_item(ii.id).clean(cx))
.collect::<Vec<_>>()
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
(
item_ids.iter()
.map(|ii| tcx.hir.impl_item(ii.id).clean(cx))
.collect::<Vec<_>>(),
gen.clean(cx),
)
}
_ => panic!("did given to build_impl was not an impl"),
}
} else {
tcx.associated_items(did).filter_map(|item| {
if associated_trait.is_some() || item.vis == ty::Visibility::Public {
Some(item.clean(cx))
} else {
None
}
}).collect::<Vec<_>>()
(
tcx.associated_items(did).filter_map(|item| {
if associated_trait.is_some() || item.vis == ty::Visibility::Public {
Some(item.clean(cx))
} else {
None
}
}).collect::<Vec<_>>(),
(tcx.generics_of(did), &predicates).clean(cx),
)
};
let polarity = tcx.impl_polarity(did);
let trait_ = associated_trait.clean(cx).map(|bound| {
Expand Down Expand Up @@ -379,7 +385,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
ret.push(clean::Item {
inner: clean::ImplItem(clean::Impl {
unsafety: hir::Unsafety::Normal,
generics: (tcx.generics_of(did), &predicates).clean(cx),
generics,
provided_trait_methods: provided,
trait_,
for_,
Expand Down

0 comments on commit de6a897

Please sign in to comment.