]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/formats/cache.rs
Rollup merge of #90022 - hkmatsumoto:self-upper-as-generic-parameter, r=jackh726
[rust.git] / src / librustdoc / formats / cache.rs
index 00ad75964d3ab14665ca9deefdb332b71b7a4cd8..d3831450e1d87d8122a7ec2319bed199b769bbe4 100644 (file)
@@ -7,7 +7,6 @@
 use rustc_span::symbol::sym;
 
 use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType};
-use crate::config::RenderOptions;
 use crate::core::DocContext;
 use crate::fold::DocFolder;
 use crate::formats::item_type::ItemType;
@@ -15,7 +14,6 @@
 use crate::html::markdown::short_markdown_summary;
 use crate::html::render::cache::{get_index_search_type, ExternalLocation};
 use crate::html::render::IndexItem;
-use crate::visit_lib::LibEmbargoVisitor;
 
 /// This cache is used to store information about the [`clean::Crate`] being
 /// rendered in order to provide more useful documentation. This contains
@@ -29,7 +27,7 @@
 #[derive(Default)]
 crate struct Cache {
     /// Maps a type ID to all known implementations for that type. This is only
-    /// recognized for intra-crate `ResolvedPath` types, and is used to print
+    /// recognized for intra-crate [`clean::Type::Path`]s, and is used to print
     /// out extra documentation on the page of an enum/struct.
     ///
     /// The values of the map are a list of implementations and documentation
@@ -145,23 +143,18 @@ impl Cache {
         debug!(?cx.cache.crate_version);
         cx.cache.traits = krate.external_traits.take();
 
-        let mut externs = Vec::new();
-        for &cnum in cx.tcx.crates(()) {
-            externs.push(ExternalCrate { crate_num: cnum });
-            // Analyze doc-reachability for extern items
-            LibEmbargoVisitor::new(cx).visit_lib(cnum);
-        }
-
-        let RenderOptions { extern_html_root_takes_precedence, output: dst, .. } =
-            &cx.render_options;
-
         // Cache where all our extern crates are located
         // FIXME: this part is specific to HTML so it'd be nice to remove it from the common code
-        for e in externs {
+        for &crate_num in cx.tcx.crates(()) {
+            let e = ExternalCrate { crate_num };
+
             let name = e.name(tcx);
+            let render_options = &cx.render_options;
             let extern_url =
-                cx.render_options.extern_html_root_urls.get(&*name.as_str()).map(|u| &**u);
-            let location = e.location(extern_url, *extern_html_root_takes_precedence, dst, tcx);
+                render_options.extern_html_root_urls.get(&*name.as_str()).map(|u| &**u);
+            let extern_url_takes_precedence = render_options.extern_html_root_takes_precedence;
+            let dst = &render_options.output;
+            let location = e.location(extern_url, extern_url_takes_precedence, dst, tcx);
             cx.cache.extern_locations.insert(e.crate_num, location);
             cx.cache.external_paths.insert(e.def_id(), (vec![name.to_string()], ItemType::Module));
         }
@@ -408,8 +401,8 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             clean::ImplItem(ref i) => {
                 self.cache.parent_is_trait_impl = i.trait_.is_some();
                 match i.for_ {
-                    clean::ResolvedPath { did, .. } => {
-                        self.cache.parent_stack.push(did);
+                    clean::Type::Path { ref path } => {
+                        self.cache.parent_stack.push(path.def_id());
                         true
                     }
                     clean::DynTrait(ref bounds, _)
@@ -443,9 +436,9 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             // Note: matching twice to restrict the lifetime of the `i` borrow.
             let mut dids = FxHashSet::default();
             match i.for_ {
-                clean::ResolvedPath { did, .. }
-                | clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
-                    dids.insert(did);
+                clean::Type::Path { ref path }
+                | clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
+                    dids.insert(path.def_id());
                 }
                 clean::DynTrait(ref bounds, _)
                 | clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => {