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

Fix intra-doc links on pub re-exports #76082

Merged
merged 3 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
let parent_node = if item.is_fake() {
// FIXME: is this correct?
None
// If we're documenting the crate root itself, it has no parent. Use the root instead.
} else if item.def_id.is_top_level_module() {
Some(item.def_id)
} else {
let mut current = item.def_id;
// The immediate parent might not always be a module.
Expand All @@ -589,6 +592,12 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
}
current = parent;
} else {
debug!(
"{:?} has no parent (kind={:?}, original was {:?})",
current,
self.cx.tcx.def_kind(current),
item.def_id
);
break None;
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/rustdoc/intra-link-pub-use.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![deny(broken_intra_doc_links)]

/// [std::env] [g]
// FIXME: This can't be tested because rustdoc doesn't show documentation on pub re-exports.
jyn514 marked this conversation as resolved.
Show resolved Hide resolved
// Until then, comment out the `htmldocck` test.
// This test still does something; namely check that no incorrect errors are emitted when
// documenting the re-export.

// @has intra_link_pub_use/index.html
// @ has - '//a[@href="https://doc.rust-lang.org/nightly/std/env/fn.var.html"]' "std::env"
// @ has - '//a[@href="../intra_link_pub_use/fn.f.html"]' "g"
pub use f as g;

/// [std::env]
extern crate self as _;

pub fn f() {}