Skip to content

Rustdoc fails to translate Rust paths into URLs for non-inline links in footnotes #132208

Closed
@taylordotfish

Description

@taylordotfish

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>&nbsp;<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

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions