about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2020-08-29 16:32:17 -0400
committerJoshua Nelson <jyn514@gmail.com>2020-08-29 16:33:12 -0400
commit1b1935452f26593d07fa17ccbe3308901dda891b (patch)
treeac3e89b8b1d85674d7a999f09141ff25ee48ca32
parent1dc748fb3d2c54f536e6abd74f1ad34b3624f640 (diff)
downloadrust-1b1935452f26593d07fa17ccbe3308901dda891b.tar.gz
rust-1b1935452f26593d07fa17ccbe3308901dda891b.zip
[WIP] Fix intra-doc links on pub re-exports
This removes the incorrect error, but doesn't show the documentation
anywhere.
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs4
-rw-r--r--src/test/rustdoc/intra-link-pub-use.rs8
2 files changed, 12 insertions, 0 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index 65d116b9c67..be6a7e25c88 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -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.
@@ -589,6 +592,7 @@ 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;
                 }
             }
diff --git a/src/test/rustdoc/intra-link-pub-use.rs b/src/test/rustdoc/intra-link-pub-use.rs
new file mode 100644
index 00000000000..a5ceeafc80a
--- /dev/null
+++ b/src/test/rustdoc/intra-link-pub-use.rs
@@ -0,0 +1,8 @@
+#![deny(intra_doc_link_resolution_failure)]
+
+/// [std::env] [g]
+// @has intra_link_pub_use/index.html '//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;
+
+pub fn f() {}