Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove intra doc link items if they are private/hidden and the matching option is not enabled #130278

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,15 +1228,14 @@ impl Attributes {
for attr in self.other_attrs.lists(sym::doc).filter(|a| a.has_name(sym::alias)) {
if let Some(values) = attr.meta_item_list() {
for l in values {
match l.lit().unwrap().kind {
ast::LitKind::Str(s, _) => {
aliases.insert(s);
}
_ => unreachable!(),
if let Some(lit) = l.lit()
&& let ast::LitKind::Str(s, _) = lit.kind
{
aliases.insert(s);
}
}
} else {
aliases.insert(attr.value_str().unwrap());
} else if let Some(value) = attr.value_str() {
aliases.insert(value);
}
}
aliases.into_iter().collect::<Vec<_>>().into()
Expand Down
16 changes: 13 additions & 3 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use crate::clean::{self, ItemId};
use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions};
use crate::formats::cache::Cache;
use crate::passes::Condition::*;
use crate::passes::{self};
use crate::passes::collect_intra_doc_links::LinkCollector;
use crate::passes;

pub(crate) struct DocContext<'tcx> {
pub(crate) tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -440,14 +441,23 @@ pub(crate) fn run_global_ctxt(
}
}

debug!("running pass {}", passes::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS.name);
let (mut krate, LinkCollector { visited_links, ambiguous_links, .. }) =
tcx.sess.time("collect_intra_doc_links", || {
passes::collect_intra_doc_links::collect_intra_doc_links(krate, &mut ctxt)
});

krate = tcx.sess.time("create_format_cache", || Cache::populate(&mut ctxt, krate));

let mut collector = LinkCollector { cx: &mut ctxt, visited_links, ambiguous_links };
collector.resolve_ambiguities();

tcx.sess.time("check_lint_expectations", || tcx.check_expectations(Some(sym::rustdoc)));

if let Some(guar) = tcx.dcx().has_errors() {
return Err(guar);
}

krate = tcx.sess.time("create_format_cache", || Cache::populate(&mut ctxt, krate));

Ok((krate, ctxt.render_options, ctxt.cache))
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ pub(crate) struct MarkdownLink {
pub range: MarkdownLinkRange,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub(crate) enum MarkdownLinkRange {
/// Normally, markdown link warnings point only at the destination.
Destination(Range<usize>),
Expand Down
Loading
Loading