Skip to content

Commit 159236a

Browse files
committed
rustdoc: Handle associated types on inlined impls
Fix #21348
1 parent 8224e0e commit 159236a

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,21 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
319319
};
320320
Some(item)
321321
}
322-
ty::TypeTraitItem(_) => {
323-
// FIXME(pcwalton): Implement.
324-
None
322+
ty::TypeTraitItem(ref assoc_ty) => {
323+
let did = assoc_ty.def_id;
324+
let type_scheme = ty::lookup_item_type(tcx, did);
325+
// Not sure the choice of ParamSpace actually matters here, because an
326+
// associated type won't have generics on the LHS
327+
let typedef = (type_scheme, subst::ParamSpace::TypeSpace).clean(cx);
328+
Some(clean::Item {
329+
name: Some(assoc_ty.name.clean(cx)),
330+
inner: clean::TypedefItem(typedef),
331+
source: clean::Span::empty(),
332+
attrs: vec![],
333+
visibility: None,
334+
stability: stability::lookup(tcx, did).clean(cx),
335+
def_id: did
336+
})
325337
}
326338
}
327339
}).collect();

src/librustdoc/clean/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,14 +2520,14 @@ impl Clean<Item> for ty::AssociatedType {
25202520
source: DUMMY_SP.clean(cx),
25212521
name: Some(self.name.clean(cx)),
25222522
attrs: Vec::new(),
2523-
// FIXME(#18048): this is wrong, but cross-crate associated types are broken
2524-
// anyway, for the time being.
25252523
inner: AssociatedTypeItem(TyParam {
25262524
name: self.name.clean(cx),
25272525
did: ast::DefId {
25282526
krate: 0,
25292527
node: ast::DUMMY_NODE_ID
25302528
},
2529+
// FIXME(#20727): bounds are missing and need to be filled in from the
2530+
// predicates on the trait itself
25312531
bounds: vec![],
25322532
default: None,
25332533
}),
@@ -2559,6 +2559,16 @@ impl Clean<Item> for ast::Typedef {
25592559
}
25602560
}
25612561

2562+
impl<'a> Clean<Typedef> for (ty::TypeScheme<'a>, ParamSpace) {
2563+
fn clean(&self, cx: &DocContext) -> Typedef {
2564+
let (ref ty_scheme, ps) = *self;
2565+
Typedef {
2566+
type_: ty_scheme.ty.clean(cx),
2567+
generics: (&ty_scheme.generics, ps).clean(cx)
2568+
}
2569+
}
2570+
}
2571+
25622572
fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
25632573
t: ty::Ty, name: &str,
25642574
fallback: fn(Box<Type>) -> Type) -> Type {

0 commit comments

Comments
 (0)