diff options
| author | Michael Howell <michael@notriddle.com> | 2022-03-31 08:56:41 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-03-31 09:16:33 -0700 |
| commit | 2983698b203d32a5c59234c022e8ff8dc532b515 (patch) | |
| tree | bcb71b9a14c209aaadca82b09ce93859dc988b97 /src/librustdoc/clean | |
| parent | 03314912f1361af6b39383958b5aa1b4aed61c26 (diff) | |
| download | rust-2983698b203d32a5c59234c022e8ff8dc532b515.tar.gz rust-2983698b203d32a5c59234c022e8ff8dc532b515.zip | |
rustdoc: do not show primitives and keywords as private
Diffstat (limited to 'src/librustdoc/clean')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3e60ed2f7c4..81c05509c4e 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -471,14 +471,17 @@ impl Item { ) -> Item { trace!("name={:?}, def_id={:?}", name, def_id); - Item { - def_id: def_id.into(), - kind: box kind, - name, - attrs, - visibility: cx.tcx.visibility(def_id).clean(cx), - cfg, - } + // Primitives and Keywords are written in the source code as private modules. + // The modules need to be private so that nobody actually uses them, but the + // keywords and primitives that they are documenting are public. + let visibility = if matches!(&kind, ItemKind::KeywordItem(..) | ItemKind::PrimitiveItem(..)) + { + Visibility::Public + } else { + cx.tcx.visibility(def_id).clean(cx) + }; + + Item { def_id: def_id.into(), kind: box kind, name, attrs, visibility, cfg } } /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined |
