about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-06-29 06:59:28 +0200
committerGitHub <noreply@github.com>2025-06-29 06:59:28 +0200
commite5bd07ac2e1fc2a9c97f87403432c27a702fc556 (patch)
treea69238c6be143989f9b731fab4d1459a89ca6edd
parentc0e052885783877bb090293d29ea71d0bd224df8 (diff)
parent1052ddda964811c25823aa7285595f7085392b36 (diff)
downloadrust-e5bd07ac2e1fc2a9c97f87403432c27a702fc556.tar.gz
rust-e5bd07ac2e1fc2a9c97f87403432c27a702fc556.zip
Rollup merge of #142367 - GuillaumeGomez:extern-crate-items-intra-doc, r=lolbinarycat
Add regression test for #137857 to ensure that we generate intra doc links for extern crate items.

Fixes https://github.com/rust-lang/rust/issues/137857.

I checked that linking to extern crates was generating valid links (with the `/index.html` part) and since it's already working, just adding a regression test.

r? `@notriddle`
-rw-r--r--tests/rustdoc/intra-doc/deps.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/rustdoc/intra-doc/deps.rs b/tests/rustdoc/intra-doc/deps.rs
new file mode 100644
index 00000000000..fd40b8326d0
--- /dev/null
+++ b/tests/rustdoc/intra-doc/deps.rs
@@ -0,0 +1,23 @@
+// Checks that links to crates are correctly generated and only existing crates
+// have a link generated.
+// Regression test for <https://github.com/rust-lang/rust/issues/137857>.
+
+//@ compile-flags: --document-private-items -Z unstable-options
+//@ compile-flags: --extern-html-root-url=empty=https://empty.example/
+// This one is to ensure that we don't link to any item we see which has
+// an external html root URL unless it actually exists.
+//@ compile-flags: --extern-html-root-url=non_existant=https://non-existant.example/
+//@ aux-build: empty.rs
+
+#![crate_name = "foo"]
+#![expect(rustdoc::broken_intra_doc_links)]
+
+//@ has 'foo/index.html'
+//@ has - '//a[@href="https://empty.example/empty/index.html"]' 'empty'
+// There should only be one intra doc links, we should not link `non_existant`.
+//@ count - '//*[@class="docblock"]//a' 1
+//! [`empty`]
+//!
+//! [`non_existant`]
+
+extern crate empty;