Skip to content

Anchor names for some impls are not predictable #71912

Open
@nwalfield

Description

@nwalfield

I have a struct with a generic type:

struct ComponentBundle<C> {
    component: C,
    ...
}

Then I have implementations for different concrete types, e.g.,:

impl ComponentBundle<UserID> {
    ...
}

I want to link to the documentation for one of those implementations. But their anchors are called "#method.revocation_status-1", "#method.revocation_status-2", etc., which is brittle. It would be nice if the anchor names were more predictable.

Activity

kinnison

kinnison commented on May 5, 2020

@kinnison
Contributor

cc @rust-lang/rustdoc

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on May 5, 2020
nwalfield

nwalfield commented on May 5, 2020

@nwalfield
Author

As a workaround, I added <a name="userid_revocation_status"></a> to the right method's documentation and link to that. That links to the right documentation, but the link is in the documentation, not the method's signature. Also, the method isn't highlighted, which is unfortunate.

teythoon

teythoon commented on Jul 31, 2020

@teythoon

Similar, if you have multiple impl blocks for a type, their anchors are called impl, impl-1, ... which is also unpredictable.

jyn514

jyn514 commented on Aug 25, 2020

@jyn514
Member

IMO the links rustdoc generates are not and should not be stable. The fix is to use intra-doc links (#43466), which unfortunately are not yet stable (but should be stabilized in the next release: #74430). But I don't think we should change the anchors to be predictable, people shouldn't be depending on them in the first place.

kinnison

kinnison commented on Aug 25, 2020

@kinnison
Contributor

@jyn514 hard to do that across crates.

GuillaumeGomez

GuillaumeGomez commented on Aug 25, 2020

@GuillaumeGomez
Member

If it's a crate that is not one of your dependencies, it's not possible, indeed.

jyn514

jyn514 commented on Aug 25, 2020

@jyn514
Member

If it's a crate that is not one of your dependencies, it's not possible, indeed.

If it's not one of your dependencies (and in particular not your crate), then you can't depend on the anchor being present, you have to first navigate to it and be sure it's there before hard-coding it. So I don't think that's an argument to make the anchor predictable, just that doc authors should verify their links are present.

GuillaumeGomez

GuillaumeGomez commented on Aug 25, 2020

@GuillaumeGomez
Member

I personally think that the generated HTML shouldn't be generated, I was just stating a fact. ;)

kinnison

kinnison commented on Aug 25, 2020

@kinnison
Contributor

Another difficulty is linking usefully to docs from (for example) an mdbook.

jsha

jsha commented on Jan 21, 2022

@jsha
Contributor

FYI some of this is being updated in #92745 and #91759.

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

Metadata

Metadata

Assignees

No one assigned

    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

        Participants

        @jsha@teythoon@nwalfield@kinnison@GuillaumeGomez

        Issue actions

          Anchor names for some impls are not predictable · Issue #71912 · rust-lang/rust