Skip to content

Commit 17d4834

Browse files
pull impl generics from HIR if available
1 parent eaacf59 commit 17d4834

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,23 +334,29 @@ 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 = if let Some(nodeid) = tcx.hir.as_local_node_id(did) {
337+
let (trait_items, generics) = if let Some(nodeid) = tcx.hir.as_local_node_id(did) {
338338
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<_>>()
339+
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
340+
(
341+
item_ids.iter()
342+
.map(|ii| tcx.hir.impl_item(ii.id).clean(cx))
343+
.collect::<Vec<_>>(),
344+
gen.clean(cx),
345+
)
343346
}
344347
_ => panic!("did given to build_impl was not an impl"),
345348
}
346349
} 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<_>>()
350+
(
351+
tcx.associated_items(did).filter_map(|item| {
352+
if associated_trait.is_some() || item.vis == ty::Visibility::Public {
353+
Some(item.clean(cx))
354+
} else {
355+
None
356+
}
357+
}).collect::<Vec<_>>(),
358+
(tcx.generics_of(did), &predicates).clean(cx),
359+
)
354360
};
355361
let polarity = tcx.impl_polarity(did);
356362
let trait_ = associated_trait.clean(cx).map(|bound| {
@@ -378,7 +384,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
378384
ret.push(clean::Item {
379385
inner: clean::ImplItem(clean::Impl {
380386
unsafety: hir::Unsafety::Normal,
381-
generics: (tcx.generics_of(did), &predicates).clean(cx),
387+
generics,
382388
provided_trait_methods: provided,
383389
trait_,
384390
for_,

0 commit comments

Comments
 (0)