Skip to content

Commit

Permalink
rustdoc: Remove cache for preprocessed markdown links
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Feb 11, 2023
1 parent 8dabf5d commit 0e61d3a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ use crate::clean::inline::build_external_trait;
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,
Expand Down
14 changes: 2 additions & 12 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,22 +806,12 @@ impl<'a, 'tcx> DocVisitor for LinkCollector<'a, 'tcx> {
// 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() {
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/passes/collect_intra_doc_links/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0e61d3a

Please sign in to comment.