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: Resolve to wrong mod when use glob reexport and non-glob reexport together #83632

Closed
longfangsong opened this issue Mar 29, 2021 · 4 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@longfangsong
Copy link
Contributor

longfangsong commented Mar 29, 2021

I'm trying to work on #83375, but found a related but not same bug:

I run rustdoc on this code:

// resolve.rs
pub mod sub {
    pub struct Item;

    /// sub::prelude
    pub mod prelude {
        pub use super::Item;

        pub fn describe() -> &'static str {
            "sub::prelude"
        }
    }
}

pub mod sub2 {
    pub struct Item;

    /// sub2::prelude
    pub mod prelude {
        pub use super::Item;
        pub fn describe() -> &'static str {
            "sub2::prelude"
        }
    }
}

#[doc(inline)]
pub use sub::*;

#[doc(inline)]
pub use sub2::prelude;

I expected to see this happen:
Only one prelude link exists and it resolves to sub2::prelude (if you do println!("{}", resolve::prelude::describe());, you'll get the output sub2::prelude)

Instead, this happened:

  1. Similiar with Rustdoc: glob reexport may duplicate module #83375 described, there are two preludes here:

图片

  1. Moreover, if you visit either of the prelude links, it direct you to sub::prelude

截屏2021-03-29 下午3 48 43

Meta

rustdoc +local --version:

rustdoc 1.53.0-dev
Backtrace

NA

@longfangsong longfangsong added the C-bug Category: This is a bug. label Mar 29, 2021
@longfangsong
Copy link
Contributor Author

longfangsong commented Mar 29, 2021

@rustbot label: +T-rustdoc -T-doc

@rustbot rustbot added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Mar 29, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 30, 2021

Duplicate of #83375 (but thanks for the report).

@jyn514 jyn514 closed this as completed Mar 30, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 30, 2021

The reason I consider them the same is they have the same cause: if there's already an item with that name in scope, rustdoc will use both that item and the glob re-export. Whether the item is a re-export or was defined in the current module shouldn't matter.

@jyn514
Copy link
Member

jyn514 commented Mar 30, 2021

rustdoc +local --version: rustdoc 1.53.0-dev

BTW, this isn't super helpful because the version is always the same - it's more helpful to link the commit you built from source.

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. 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