Skip to content

rustdoc: intra-doc links to enum variant fields have incorrect HTML title attribute #161028

Description

@gifnksm

rustdoc generates <a title="..."> for intra-doc links, but the titles for enum variant fields seem incorrect.

I tried this code:

Cargo.toml:

[package]
name = "test"
version = "0.1.0"
edition = "2024"

src/lib.rs:

//!
//! <!--
//! START
//! -->
//! [Enum::Variant::field]
//! <!--
//! END
//! -->
//!

/// This is an enum.
pub enum Enum {
    Variant { field: i32 }
}

Run the following commands:

$ cargo +nightly doc
$ sed -n '/START/,/END/p' target/doc/test/index.html

I expected to see this happen:

The generated title attribute is field test::Enum::Variant::field

Instead, this happened:

Generated title attribute is field test::Enum::field (Variant is missing)

$ sed -n '/START/,/END/p' target/doc/test/index.html
START
-->
<p><a href="enum.Enum.html#variant.Variant.field.field" title="field test::Enum::field">Enum::Variant::field</a></p>
<!--
END

Meta

rustc --version --verbose:

$ rustc +nightly -vV
rustc 1.99.0-nightly (c98d0cb27 2026-08-12)
binary: rustc
commit-hash: c98d0cb27cc63afdd62602a52eb4feb8a1c682dd
commit-date: 2026-08-12
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0
Backtrace

<backtrace>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-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