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

rustdoc: don't process Crate::external_traits when collecting intra-doc links #58972

Merged
merged 2 commits into from
Apr 11, 2019
Merged
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
10 changes: 10 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ impl<'a, 'tcx, 'rcx> LinkCollector<'a, 'tcx, 'rcx> {
_ => Err(())
}
} else {
debug!("attempting to resolve item without parent module: {}", path_str);
Err(())
}
}
Expand Down Expand Up @@ -434,6 +435,15 @@ impl<'a, 'tcx, 'rcx> DocFolder for LinkCollector<'a, 'tcx, 'rcx> {
self.fold_item_recur(item)
}
}

// FIXME: if we can resolve intra-doc links from other crates, we can use the stock
// `fold_crate`, but until then we should avoid scanning `krate.external_traits` since those
// will never resolve properly
fn fold_crate(&mut self, mut c: Crate) -> Crate {
c.module = c.module.take().and_then(|module| self.fold_item(module));

c
}
}

/// Resolves a string as a macro.
Expand Down
6 changes: 6 additions & 0 deletions src/test/rustdoc/auxiliary/intra-links-external-traits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub trait ThisTrait {
fn asdf(&self);

/// let's link to [`asdf`](ThisTrait::asdf)
fn qwop(&self);
}
12 changes: 12 additions & 0 deletions src/test/rustdoc/intra-links-external-traits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// aux-build:intra-links-external-traits.rs
// ignore-cross-compile

#![crate_name = "outer"]
#![deny(intra_doc_link_resolution_failure)]

// using a trait that has intra-doc links on it from another crate (whether re-exporting or just
// implementing it) used to give spurious resolution failure warnings

extern crate intra_links_external_traits;

pub use intra_links_external_traits::ThisTrait;