summary refs log tree commit diff
path: root/tests/rustdoc
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-12-19 16:48:09 +0800
committerGitHub <noreply@github.com>2024-12-19 16:48:09 +0800
commitbd6ed18260c82d5ddf6fc042d3736b3ef5382743 (patch)
treee0b883bf0a4d24882f2641f913127ba05c6c7790 /tests/rustdoc
parentaa90dbcf13f94c864fda01856157289474821292 (diff)
parenta01de760bbcbbdf6935f0cd82107d48529c48138 (diff)
downloadrust-bd6ed18260c82d5ddf6fc042d3736b3ef5382743.tar.gz
rust-bd6ed18260c82d5ddf6fc042d3736b3ef5382743.zip
Rollup merge of #134432 - GuillaumeGomez:intra-doc-in-footnotes, r=notriddle
Fix intra doc links not generated inside footnote definitions

Fixes #132208.

The problem was that we were running the `Footnote` "pass" before the `LinkReplacer` one. Sadly, the change is bigger than it should because we can't specialize the `Iterator` trait implementation, forcing me to add a new type to handle the other `Iterator` kind (the one which still has the `Range`).

r? ``@notriddle``
Diffstat (limited to 'tests/rustdoc')
-rw-r--r--tests/rustdoc/intra-doc/link-in-footnotes-132208.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/rustdoc/intra-doc/link-in-footnotes-132208.rs b/tests/rustdoc/intra-doc/link-in-footnotes-132208.rs
new file mode 100644
index 00000000000..c9b97eafd2f
--- /dev/null
+++ b/tests/rustdoc/intra-doc/link-in-footnotes-132208.rs
@@ -0,0 +1,24 @@
+// Rustdoc has multiple passes and if the footnote pass is run before the link replacer
+// one, intra doc links are not generated inside footnote definitions. This test
+// therefore ensures that intra-doc link are correctly generated inside footnote
+// definitions.
+//
+// Regression test for <https://github.com/rust-lang/rust/issues/132208>.
+
+#![crate_name = "foo"]
+
+//@ has 'foo/index.html'
+//@ has - '//*[@class="docblock"]//a[@href="struct.Bar.html"]' 'a'
+//@ has - '//*[@class="docblock"]//*[@class="footnotes"]//a[@href="struct.Foo.html"]' 'b'
+
+//! [a]: crate::Bar
+//! [b]: crate::Foo
+//!
+//! link in body: [a]
+//!
+//! see footnote[^1]
+//!
+//! [^1]: link in footnote: [b]
+
+pub struct Bar;
+pub struct Foo;