rust/src/librustdoc
bors 2e055d92e0 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.
2021-11-23 03:13:26 +00:00
..
clean Auto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514 2021-11-23 03:13:26 +00:00
doctest Rename --display-warnings to --display-doctest-warnings 2021-09-14 10:49:56 +02:00
formats rustdoc: Move doc-reachability visiting back to cleaning 2021-11-19 22:00:37 -05:00
html Rollup merge of #91102 - jsha:theme-anchor, r=GuillaumeGomez 2021-11-22 23:30:29 +01:00
json rustdoc: Use ty::ImplPolarity instead of custom enum 2021-11-07 08:57:33 -08:00
passes Use fast comparison against kw::Empty 2021-11-19 11:34:41 -05:00
theme Clean up rustdoc static files 2021-07-07 17:52:18 +02:00
Cargo.toml rustdoc: Switch to mainline rayon 2021-10-28 18:26:57 -07:00
config.rs Fix clippy lints in librustdoc 2021-10-25 11:30:09 +02:00
core.rs rustdoc: Pass DocContext to Cache::populate 2021-11-19 17:55:40 -05:00
docfs.rs rustdoc: Remove a single-use macro 2021-10-28 18:39:32 -07:00
doctest.rs rustdoc doctest: detect fn main after an unexpected semicolon 2021-11-18 16:23:18 -07:00
error.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
externalfiles.rs rustdoc: Fix some unescaped HTML tags in docs 2021-11-19 15:54:05 -05:00
fold.rs rustdoc: Use conditional for _stripped fold 2021-11-04 09:43:13 -07:00
lib.rs Delete rustdoc::doctree 2021-11-13 21:50:13 +08:00
lint.rs Warn when rustdoc:: group is omitted from lint names 2021-07-03 15:32:09 -04:00
markdown.rs heading_level: u32 -> heading_offset: HeadingOffset 2021-10-04 22:28:04 -04:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
scrape_examples.rs Auto merge of #90635 - matthiaskrgr:rustdoc_compl, r=GuillaumeGomez 2021-11-07 02:17:35 +00:00
theme.rs Change librustdoc write(.. \n) to writeln(..); fix comment in grammar 2021-05-03 02:19:57 -05:00
visit.rs List all cases explicitly in Doc{Folder,Visitor} 2021-11-01 16:15:46 -07:00
visit_ast.rs Delete rustdoc::doctree 2021-11-13 21:50:13 +08:00
visit_lib.rs Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00

For more information about how librustdoc works, see the rustc dev guide.