Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Incorrect link to item when the item is reexported and inlined #83976

Open
SamRodri opened this issue Apr 7, 2021 · 2 comments
Open
Labels
C-bug Category: This is a bug. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@SamRodri
Copy link

SamRodri commented Apr 7, 2021

Building the documentation of this code using cargo doc generates a link to the wrong page:

pub mod some {
    pub mod path {
        pub struct Foo;
    }

    #[doc(inline)]
    pub use path::Foo as Bar;
}

/// Link to [`Foo`](crate::some::path::Foo).
pub struct Test;

I expected a link to the some/path/struct.Foo.html page, but got a link to the some/struct.Bar.html page.

Meta

The error happens in the stable 1.51.0 and nightly 2021-04-07 versions.

@SamRodri SamRodri added the C-bug Category: This is a bug. label Apr 7, 2021
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 7, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 7, 2021

I think the issue is that rustdoc tracks URLs by item, not by re-export:

let (fqp, shortty, mut url) = match cache.paths.get(&did) {

So the URL gets overridden because the re-export and the original item have the same DefId.

@jyn514 jyn514 added the E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. label Apr 7, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 7, 2021

Note this isn't specific to intra-doc links, this also links to Bar:

pub fn f() -> crate::some::path::Foo {
    Foo
}

@jyn514 jyn514 changed the title rustdoc: Incorrect intra-doc link to item when the item is reexported and inlined rustdoc: Incorrect link to item when the item is reexported and inlined Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants