Skip to content

Intra-doc links choose a random method if there are multiple implementations of the same generic trait #76895

Open
@jyn514

Description

@jyn514
Member

This is case three from #74489.

If a type implements a trait that's generic and implemented multiple times with different generic parameters, then rustdoc generates the same link for each. For example, [String::from] resolves to https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from.

However, every From implementation on String has a method called from! So the browser picks a random one.

This requires two fixes:

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
A-associated-itemsArea: Associated items (types, constants & functions)
C-bugCategory: This is a bug.
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by name
on Sep 18, 2020
camelid

camelid commented on Dec 17, 2021

@camelid
Member

rustdoc needs to change the #method.from it generates to distinguish the different functions in the browser

cc #92052

self-assigned this
on Nov 7, 2024
lolbinarycat

lolbinarycat commented on Nov 7, 2024

@lolbinarycat
Contributor

took a shot at the second part, in theory it should be pretty easy to just prepend the impl disambiguator, but i can't find the code that generates the fragment just by traversing the call graph.

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

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)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

      Participants

      @Manishearth@lolbinarycat@jyn514@camelid

      Issue actions

        Intra-doc links choose a random method if there are multiple implementations of the same generic trait · Issue #76895 · rust-lang/rust