Skip to content

Commit de6a897

Browse files
pull impl generics from HIR if available
1 parent fe26efe commit de6a897

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/librustdoc/clean/inline.rs

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

0 commit comments

Comments
 (0)