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 fails to follow path after re-export. #72056

Closed
gyscos opened this issue May 9, 2020 · 3 comments
Closed

Rustdoc fails to follow path after re-export. #72056

gyscos opened this issue May 9, 2020 · 3 comments
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@gyscos
Copy link

gyscos commented May 9, 2020

When re-exporting modules from another crate, documentation for this crate does not follow rust paths correctly.

A simple workspace to showcase the issue:

  • A foo crate, with a foo module and a Foo struct in this module. The foo module has documentation linking to the Foo struct.
  • A bar crate which depends on foo with the line pub use foo::*;
    From there, compiling documentation will:
  • For the crate foo, correctly resolve the Foo link.
  • For the crate bar, incorrectly resolve the link in the re-exported foo module.
# foo/src/lib.rs
pub mod foo {
    //! A mod.
    //!
    //! See [`Foo`]

    /// Some struct
    pub struct Foo;
}
# bar/src/lib.rs
pub use ::foo::*;

Here is a screenshot from the doc page for the foo module from the foo crate:
Screenshot from 2020-05-09 10-45-57

And here is the documentation for the foo module re-exported in the bar crate:
Screenshot from 2020-05-09 10-46-09

Here is a zip with the entire workspace ready to compile: rustdoc example.zip

I also tried using self::Foo, crate::foo::Foo, for the same result.

Apart from this simple example, this can happen with "facade" crates that re-export all or a subset of an other crate, and expect documentation to transparently work.

@gyscos gyscos added the C-bug Category: This is a bug. label May 9, 2020
@jonas-schievink jonas-schievink added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 9, 2020
@ehuss
Copy link
Contributor

ehuss commented May 9, 2020

This appears to be a duplicate of #65983.

@gyscos
Copy link
Author

gyscos commented May 9, 2020

Arf, missed that, sorry!
The source post from #65983 looks more complex though, with [Baz] expected to point back to the source, though that may be just a superficial difference.

@gyscos gyscos closed this as completed May 9, 2020
@gyscos
Copy link
Author

gyscos commented May 9, 2020

Actually in my case I'd be very much fine with local resolution, pointing to the re-exported item as long as the module structure is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. 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