diff --git a/tests/rustdoc/intra-doc/deps.rs b/tests/rustdoc/intra-doc/deps.rs new file mode 100644 index 0000000000000..b13145ab595e8 --- /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 . + +//@ 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 "by default" any item we see which has +// an external html root URL. +//@ compile-flags: --extern-html-root-url=non_existent=https://empty.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_existent`. +//@ count - '//*[@class="docblock"]//a' 1 +//! [`empty`] +//! +//! [`non_existent`] + +extern crate empty;