]> git.lizzy.rs Git - rust.git/commit
Auto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514
authorbors <bors@rust-lang.org>
Tue, 23 Nov 2021 03:13:26 +0000 (03:13 +0000)
committerbors <bors@rust-lang.org>
Tue, 23 Nov 2021 03:13:26 +0000 (03:13 +0000)
commit2e055d92e0d527b273d12584bd842f6527e7652c
treec080a888a183d63a7bcfd4d0210e54e89dfcd415
parent8d0c79d26995a973c6f33c32ffb0c827d78bb213
parent3c510383c4149411ea23b18a7d0048fc3c5a17cc
Auto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514

Avoid documenting top-level private imports

PR #88447 aimed to make rustdoc's `--document-private-items` mode only document imports that are visible outside the importing module. Unfortunately, I inadvertently set things up so that imports at the crate top-level are always documented, regardless of their visibility. This behavior was unintended and is [not desirable](https://github.com/rust-lang/rust/issues/90865#issuecomment-971172649).

This PR treats top-level imports as never being visible outside their parent module. In practice, the only way a top-level import can be visible externally is if it's fully public, and there's a seperate check for that.

It's worth calling attention to the fact that this change means that `pub(crate)` imports will be visible in lower level modules, but not at the top-level. This is because, at the top level of the crate, `pub(crate)` means the same thing as `pub(self)`.

It turned out that there were existing tests checking for the only behavior, which I didn't notice at the time of my previous PR. I have updated them to check for the new behavior and substantially extended them to handle differences between the top-level module and lower level modules. I may have gone overboard, so please tell me if there's anything I should cut.

r? `@jyn514`

Fixes #90865.
src/librustdoc/clean/mod.rs