]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/passes/collect_trait_impls.rs
Use () for all_traits.
[rust.git] / src / librustdoc / passes / collect_trait_impls.rs
index 7b0b2f28fdfff384bd7dd122031dcf122735cf4a..564408768f72d451c2fe9c8d28696f2ec55752e7 100644 (file)
@@ -4,7 +4,7 @@
 use crate::fold::DocFolder;
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
-use rustc_hir::def_id::{DefId, LOCAL_CRATE};
+use rustc_hir::def_id::DefId;
 use rustc_middle::ty::DefIdTree;
 use rustc_span::symbol::sym;
 
@@ -46,7 +46,7 @@
 
                 // FIXME(eddyb) is this `doc(hidden)` check needed?
                 if !cx.tcx.get_attrs(def_id).lists(sym::doc).has_word(sym::hidden) {
-                    let impls = get_auto_trait_and_blanket_impls(cx, def_id);
+                    let impls = get_auto_trait_and_blanket_impls(cx, def_id.into());
                     new_items.extend(impls.filter(|i| cx.inlined.insert(i.def_id)));
                 }
             });
@@ -56,7 +56,7 @@
     // `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations`
     // doesn't work with it anyway, so pull them from the HIR map instead
     let mut extra_attrs = Vec::new();
-    for &trait_did in cx.tcx.all_traits(LOCAL_CRATE).iter() {
+    for &trait_did in cx.tcx.all_traits(()).iter() {
         for &impl_did in cx.tcx.hir().trait_impls(trait_did) {
             let impl_did = impl_did.to_def_id();
             cx.tcx.sess.prof.generic_activity("build_local_trait_impl").run(|| {
@@ -117,8 +117,8 @@ fn add_deref_target(
                     // Avoid infinite cycles
                     return;
                 }
-                cleaner.items.insert(target_did);
-                add_deref_target(map, cleaner, &target_did);
+                cleaner.items.insert(target_did.into());
+                add_deref_target(map, cleaner, &target_did.into());
             }
         }
     }
@@ -126,7 +126,7 @@ fn add_deref_target(
         // Since only the `DefId` portion of the `Type` instances is known to be same for both the
         // `Deref` target type and the impl for type positions, this map of types is keyed by
         // `DefId` and for convenience uses a special cleaner that accepts `DefId`s directly.
-        if cleaner.keep_impl_with_def_id(type_did) {
+        if cleaner.keep_impl_with_def_id(&FakeDefId::new_real(*type_did)) {
             add_deref_target(&type_did_to_deref_target, &mut cleaner, type_did);
         }
     }
@@ -163,8 +163,10 @@ impl<'a, 'tcx> DocFolder for SyntheticImplCollector<'a, 'tcx> {
     fn fold_item(&mut self, i: Item) -> Option<Item> {
         if i.is_struct() || i.is_enum() || i.is_union() {
             // FIXME(eddyb) is this `doc(hidden)` check needed?
-            if !self.cx.tcx.get_attrs(i.def_id).lists(sym::doc).has_word(sym::hidden) {
-                self.impls.extend(get_auto_trait_and_blanket_impls(self.cx, i.def_id));
+            if !self.cx.tcx.get_attrs(i.def_id.expect_real()).lists(sym::doc).has_word(sym::hidden)
+            {
+                self.impls
+                    .extend(get_auto_trait_and_blanket_impls(self.cx, i.def_id.expect_real()));
             }
         }
 
@@ -174,7 +176,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
 
 #[derive(Default)]
 struct ItemCollector {
-    items: FxHashSet<DefId>,
+    items: FxHashSet<FakeDefId>,
 }
 
 impl ItemCollector {
@@ -193,7 +195,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
 
 struct BadImplStripper {
     prims: FxHashSet<PrimitiveType>,
-    items: FxHashSet<DefId>,
+    items: FxHashSet<FakeDefId>,
 }
 
 impl BadImplStripper {
@@ -204,13 +206,13 @@ fn keep_impl(&self, ty: &Type) -> bool {
         } else if let Some(prim) = ty.primitive_type() {
             self.prims.contains(&prim)
         } else if let Some(did) = ty.def_id() {
-            self.keep_impl_with_def_id(&did)
+            self.keep_impl_with_def_id(&did.into())
         } else {
             false
         }
     }
 
-    fn keep_impl_with_def_id(&self, did: &DefId) -> bool {
+    fn keep_impl_with_def_id(&self, did: &FakeDefId) -> bool {
         self.items.contains(did)
     }
 }