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. |
||
|---|---|---|
| .. | ||
| clean | ||
| doctest | ||
| formats | ||
| html | ||
| json | ||
| passes | ||
| theme | ||
| Cargo.toml | ||
| config.rs | ||
| core.rs | ||
| docfs.rs | ||
| doctest.rs | ||
| error.rs | ||
| externalfiles.rs | ||
| fold.rs | ||
| lib.rs | ||
| lint.rs | ||
| markdown.rs | ||
| README.md | ||
| scrape_examples.rs | ||
| theme.rs | ||
| visit.rs | ||
| visit_ast.rs | ||
| visit_lib.rs | ||
For more information about how librustdoc works, see the rustc dev guide.