-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
Rustdoc incorrectly renders non-inline links (those whose destinations are defined in link reference definitions) if the link occurs in a footnote and points to a Rust item. Rather than translating the Rust path into the corresponding documentation URL, the path is simply emitted verbatim as the link's href
.
Example
With the following in src/lib.rs
:
//! [a]: std::vec::Vec
//!
//! link in body: [a]
//!
//! see footnote[^1]
//!
//! [^1]: link in footnote: [a]
cargo doc
produces the following HTML:
<p>link in body: <a href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">a</a></p>
<p>see footnote<sup id="fnref1"><a href="#fn1">1</a></sup></p>
<div class="footnotes"><hr><ol><li id="fn1"><p>link in footnote: <a href="std::vec::Vec">a</a> <a href="#fnref1">↩</a></p></li></ol></div>
The first link correctly leads to Vec
's HTML documentation, but the second link is rendered literally as <a href="std::vec::Vec">
.
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (c1db4dc24 2024-10-25)
binary: rustc
commit-hash: c1db4dc24267a707409c9bf2e67cf3c7323975c8
commit-date: 2024-10-25
host: powerpc64le-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
Metadata
Metadata
Assignees
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.