]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/clean/mod.rs
Add `constness` field to `ty::Predicate::Trait`
[rust.git] / src / librustdoc / clean / mod.rs
index 0cc4c55f49be82b335a5ff945298e61945415455..7a7d69c68a585aaacae347bf9de867799e99ef22 100644 (file)
@@ -482,7 +482,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
         use rustc::ty::Predicate;
 
         match *self {
-            Predicate::Trait(ref pred) => Some(pred.clean(cx)),
+            Predicate::Trait(ref pred, _) => Some(pred.clean(cx)),
             Predicate::Subtype(ref pred) => Some(pred.clean(cx)),
             Predicate::RegionOutlives(ref pred) => pred.clean(cx),
             Predicate::TypeOutlives(ref pred) => pred.clean(cx),
@@ -1124,14 +1124,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
             hir::ImplItemKind::TyAlias(ref ty) => {
                 let type_ = ty.clean(cx);
                 let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
-                TypedefItem(
-                    Typedef {
-                        type_,
-                        generics: Generics::default(),
-                        item_type,
-                    },
-                    true,
-                )
+                TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true)
             }
             hir::ImplItemKind::OpaqueTy(ref bounds) => OpaqueTyItem(
                 OpaqueTy { bounds: bounds.clean(cx), generics: Generics::default() },
@@ -2011,14 +2004,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
             visibility: self.vis.clean(cx),
             stability: cx.stability(self.id).clean(cx),
             deprecation: cx.deprecation(self.id).clean(cx),
-            inner: TypedefItem(
-                Typedef {
-                    type_,
-                    generics: self.gen.clean(cx),
-                    item_type,
-                },
-                false,
-            ),
+            inner: TypedefItem(Typedef { type_, generics: self.gen.clean(cx), item_type }, false),
         }
     }
 }
@@ -2119,7 +2105,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
             build_deref_target_impls(cx, &items, &mut ret);
         }
 
-        let provided = trait_
+        let provided: FxHashSet<String> = trait_
             .def_id()
             .map(|did| {
                 cx.tcx
@@ -2130,7 +2116,12 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
             })
             .unwrap_or_default();
 
-        ret.push(Item {
+        let for_ = self.for_.clean(cx);
+        let type_alias = for_.def_id().and_then(|did| match cx.tcx.def_kind(did) {
+            Some(DefKind::TyAlias) => Some(cx.tcx.type_of(did).clean(cx)),
+            _ => None,
+        });
+        let make_item = |trait_: Option<Type>, for_: Type, items: Vec<Item>| Item {
             name: None,
             attrs: self.attrs.clean(cx),
             source: self.whence.clean(cx),
@@ -2141,15 +2132,19 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
             inner: ImplItem(Impl {
                 unsafety: self.unsafety,
                 generics: self.generics.clean(cx),
-                provided_trait_methods: provided,
+                provided_trait_methods: provided.clone(),
                 trait_,
-                for_: self.for_.clean(cx),
+                for_,
                 items,
                 polarity: Some(cx.tcx.impl_polarity(def_id).clean(cx)),
                 synthetic: false,
                 blanket_impl: None,
             }),
-        });
+        };
+        if let Some(type_alias) = type_alias {
+            ret.push(make_item(trait_.clone(), type_alias, items.clone()));
+        }
+        ret.push(make_item(trait_, for_, items));
         ret
     }
 }