Skip to content

rustdoc: Two modules with the same name that are re-exported show up twice with only the contents of the first one #43935

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

Closed
sdroege opened this issue Aug 17, 2017 · 4 comments
Labels
C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@sdroege
Copy link
Contributor

sdroege commented Aug 17, 2017

https://github.com/sdroege/gstreamer-rs/tree/50a1535771d711b419eee499fb6b7c48d72edd86

Here there is auto::functions and functions re-exported in lib.rs. The module functions appears twice on the main page of the docs, but only shows the content of the first module.

Also functions/etc exported from the second module do not show up anywhere (in the module index for example) unless searching for them explicitly by name.

Also in this case, auto::functions::* and functions::* are re-exported from lib.rs, but only the contents of the first module show up, e.g. on the main page for functions/structs/etc. When searching explicitly by name, they are found nonetheless.

For rustc, exporting a module name twice causes the module to be merged.

@GuillaumeGomez

@durka
Copy link
Contributor

durka commented Aug 19, 2017

For rustc, exporting a module name twice causes the module to be merged.

Whoa. Is that an intended feature?? What if there are items with the same name after merging‽

@sdroege
Copy link
Contributor Author

sdroege commented Aug 19, 2017

Probably nothing until you try to use it, then you need to specify which of the two by giving an unambiguous path. It's probably not handled differently than importing things into the current module's namespace, where you can also have conflicts.

Seems consistent to me, and useful, even if maybe not intentional.

FWIW, in my case it is:

mod auto;
pub use auto::*; // which has a functions sub-module
pub mod functions;

If that was forbidden, adding sub-modules would become a potentially breaking API change as it could cause a conflict in e.g. a completely different crate that re-exports things like above. That would seem undesirable. Just like adding other items to a module can cause conflicts like this, it shouldn't be a problem unless it's actually used, for the same reason. You wouldn't be able to add anything to your modules anymore without potentially breaking other people's code.

@petrochenkov petrochenkov added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 19, 2017
@petrochenkov
Copy link
Contributor

Is that an intended feature?

Yes.

"exporting a module name twice causes the module to be merged" is a bit weird wording for this though.
"Non-globs shadow globs" and "conflicts glob vs glob are not reported eagerly" would describe the situation better.

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Aug 20, 2017
@jyn514
Copy link
Member

jyn514 commented Apr 27, 2021

Duplicate of #83375 (this was reported earlier, but doesn't have an MCVE).

@jyn514 jyn514 closed this as completed Apr 27, 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. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. 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

5 participants