]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Handle associated types on inlined impls
authorTom Jakubowski <tom@crystae.net>
Sun, 18 Jan 2015 06:39:01 +0000 (22:39 -0800)
committerTom Jakubowski <tom@crystae.net>
Sun, 18 Jan 2015 06:54:24 +0000 (22:54 -0800)
Fix #21348

src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs

index 432748b40e439d9da9dd1901e7f7a57d2b03ab3f..21e0fee33ddaff5c7acd235ba2eaaf325353e904 100644 (file)
@@ -319,9 +319,21 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
                 };
                 Some(item)
             }
-            ty::TypeTraitItem(_) => {
-                // FIXME(pcwalton): Implement.
-                None
+            ty::TypeTraitItem(ref assoc_ty) => {
+                let did = assoc_ty.def_id;
+                let type_scheme = ty::lookup_item_type(tcx, did);
+                // Not sure the choice of ParamSpace actually matters here, because an
+                // associated type won't have generics on the LHS
+                let typedef = (type_scheme, subst::ParamSpace::TypeSpace).clean(cx);
+                Some(clean::Item {
+                    name: Some(assoc_ty.name.clean(cx)),
+                    inner: clean::TypedefItem(typedef),
+                    source: clean::Span::empty(),
+                    attrs: vec![],
+                    visibility: None,
+                    stability: stability::lookup(tcx, did).clean(cx),
+                    def_id: did
+                })
             }
         }
     }).collect();
index a522cbf72fa90d2bd61af42208ea1c1678ed85c1..0d82efbdbdeabd8e875c4d12009060489c5f17b7 100644 (file)
@@ -2520,14 +2520,14 @@ fn clean(&self, cx: &DocContext) -> Item {
             source: DUMMY_SP.clean(cx),
             name: Some(self.name.clean(cx)),
             attrs: Vec::new(),
-            // FIXME(#18048): this is wrong, but cross-crate associated types are broken
-            // anyway, for the time being.
             inner: AssociatedTypeItem(TyParam {
                 name: self.name.clean(cx),
                 did: ast::DefId {
                     krate: 0,
                     node: ast::DUMMY_NODE_ID
                 },
+                // FIXME(#20727): bounds are missing and need to be filled in from the
+                // predicates on the trait itself
                 bounds: vec![],
                 default: None,
             }),
@@ -2559,6 +2559,16 @@ fn clean(&self, cx: &DocContext) -> Item {
     }
 }
 
+impl<'a> Clean<Typedef> for (ty::TypeScheme<'a>, ParamSpace) {
+    fn clean(&self, cx: &DocContext) -> Typedef {
+        let (ref ty_scheme, ps) = *self;
+        Typedef {
+            type_: ty_scheme.ty.clean(cx),
+            generics: (&ty_scheme.generics, ps).clean(cx)
+        }
+    }
+}
+
 fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
                t: ty::Ty, name: &str,
                fallback: fn(Box<Type>) -> Type) -> Type {