Skip to content

rustdoc doesn't properly link used trait associated items #148008

@clarfonthey

Description

@clarfonthey

Code

#![feature(import_trait_associated_functions)]
pub trait Test {
    fn method();
    const CONST: usize;
    type Type;
}

pub use self::Test::{method, CONST, Type};

Expected Outcome

The links for method, CONST, and Type re-exports should link to #tymethod.method, #asscociatedconst.CONST, and #associatedtype.Type rather than just the trait.

Actual Output

Generated rustdoc (relevant bits):

<h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">[§](https://github.com/rust-lang/rust/issues/new?template=rustdoc.md#reexports)</a></h2><dl class="item-table reexports"><dt id="reexport.[method](https://github.com/rust-lang/rust/issues/trait.Test.html)"><code>pub use self::Test::<a class="trait" href="trait.Test.html" title="trait rustdoc_issue::Test">method</a>;</code></dt><dt id="reexport.[CONST](https://github.com/rust-lang/rust/issues/trait.Test.html)"><code>pub use self::Test::<a class="trait" href="trait.Test.html" title="trait rustdoc_issue::Test">CONST</a>;</code></dt><dt id="reexport.[Type](https://github.com/rust-lang/rust/issues/trait.Test.html)"><code>pub use self::Test::<a class="trait" href="trait.Test.html" title="trait rustdoc_issue::Test">Type</a>;</code></dt></dl>

Note all the links go to just trait.Test.html without any anchors.

Version

$ rustdoc --version
rustdoc 1.92.0-nightly (57ef8d642 2025-10-15)

Additional Details

Tracking issue: #134691

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-import_trait_associated_functions`#![feature(import_trait_associated_functions)]`T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions