From 0e61d3ab3f6205ce0906837be25d5cf3ec1b2730 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 11 Feb 2023 22:23:17 +0400 Subject: [PATCH] rustdoc: Remove cache for preprocessed markdown links --- src/librustdoc/core.rs | 2 -- src/librustdoc/passes/collect_intra_doc_links.rs | 14 ++------------ .../passes/collect_intra_doc_links/early.rs | 1 - 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index d85749cadbd..a26c25c9782 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -27,13 +27,11 @@ use crate::clean::{self, ItemId}; use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions}; use crate::formats::cache::Cache; -use crate::passes::collect_intra_doc_links::PreprocessedMarkdownLink; use crate::passes::{self, Condition::*}; pub(crate) use rustc_session::config::{Input, Options, UnstableOptions}; pub(crate) struct ResolverCaches { - pub(crate) markdown_links: Option>>, pub(crate) all_trait_impls: Option>, pub(crate) all_macro_rules: FxHashMap>, pub(crate) extern_doc_reachable: DefIdSet, diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 692adcf0a80..257ad655c90 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -806,22 +806,12 @@ fn visit_item(&mut self, item: &Item) { // NOTE: if there are links that start in one crate and end in another, this will not resolve them. // This is a degenerate case and it's not supported by rustdoc. let parent_node = parent_module.or(parent_node); - let mut tmp_links = self - .cx - .resolver_caches - .markdown_links - .take() - .expect("`markdown_links` are already borrowed"); - if !tmp_links.contains_key(&doc) { - tmp_links.insert(doc.clone(), preprocessed_markdown_links(&doc)); - } - for md_link in &tmp_links[&doc] { - let link = self.resolve_link(item, &doc, parent_node, md_link); + for md_link in preprocessed_markdown_links(&doc) { + let link = self.resolve_link(item, &doc, parent_node, &md_link); if let Some(link) = link { self.cx.cache.intra_doc_links.entry(item.item_id).or_default().push(link); } } - self.cx.resolver_caches.markdown_links = Some(tmp_links); } if item.is_mod() { diff --git a/src/librustdoc/passes/collect_intra_doc_links/early.rs b/src/librustdoc/passes/collect_intra_doc_links/early.rs index 75c3380ee9b..ec449e94ce5 100644 --- a/src/librustdoc/passes/collect_intra_doc_links/early.rs +++ b/src/librustdoc/passes/collect_intra_doc_links/early.rs @@ -24,7 +24,6 @@ pub(crate) fn early_resolve_intra_doc_links( link_resolver.process_extern_impls(); ResolverCaches { - markdown_links: Some(Default::default()), all_trait_impls: Some(link_resolver.all_trait_impls), all_macro_rules: link_resolver.all_macro_rules, extern_doc_reachable: link_resolver.extern_doc_reachable,