Auto merge of #107933 - petrochenkov:rmdlc, r=GuillaumeGomez

rustdoc: Remove cache for preprocessed markdown links

It's quite possible that it's no longer useful after https://github.com/rust-lang/rust/pull/94857 is merged.
This commit is contained in:
bors 2023-02-12 14:28:43 +00:00
commit 00cf19a75a
3 changed files with 2 additions and 15 deletions

View File

@ -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<FxHashMap<String, Vec<PreprocessedMarkdownLink>>>,
pub(crate) all_trait_impls: Option<Vec<DefId>>,
pub(crate) all_macro_rules: FxHashMap<Symbol, Res<NodeId>>,
pub(crate) extern_doc_reachable: DefIdSet,

View File

@ -807,22 +807,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() {

View File

@ -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,