From fc16b815cc204b3fe7d31b9918a8fa3c17a5eef3 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 21 Jan 2022 18:41:34 -0800 Subject: [PATCH] rustdoc: Make some `pub` items crate-private They don't need to be `pub`. Making them crate-private improves code clarity and `dead_code` linting. --- src/librustdoc/clean/types.rs | 20 +++++++++---------- src/librustdoc/core.rs | 4 ++-- src/librustdoc/html/render/mod.rs | 2 +- .../passes/collect_intra_doc_links.rs | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 993503005d7df..0c0787c6b2f7f 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -429,7 +429,7 @@ impl Item { /// Convenience wrapper around [`Self::from_def_id_and_parts`] which converts /// `hir_id` to a [`DefId`] - pub fn from_hir_id_and_parts( + crate fn from_hir_id_and_parts( hir_id: hir::HirId, name: Option, kind: ItemKind, @@ -438,7 +438,7 @@ impl Item { Item::from_def_id_and_parts(cx.tcx.hir().local_def_id(hir_id).to_def_id(), name, kind, cx) } - pub fn from_def_id_and_parts( + crate fn from_def_id_and_parts( def_id: DefId, name: Option, kind: ItemKind, @@ -456,7 +456,7 @@ impl Item { ) } - pub fn from_def_id_and_attrs_and_parts( + crate fn from_def_id_and_attrs_and_parts( def_id: DefId, name: Option, kind: ItemKind, @@ -984,26 +984,26 @@ crate fn collapse_doc_fragments(doc_strings: &[DocFragment]) -> String { #[derive(Clone, Debug, PartialEq, Eq, Hash)] crate struct ItemLink { /// The original link written in the markdown - pub(crate) link: String, + crate link: String, /// The link text displayed in the HTML. /// /// This may not be the same as `link` if there was a disambiguator /// in an intra-doc link (e.g. \[`fn@f`\]) - pub(crate) link_text: String, - pub(crate) did: DefId, + crate link_text: String, + crate did: DefId, /// The url fragment to append to the link - pub(crate) fragment: Option, + crate fragment: Option, } pub struct RenderedLink { /// The text the link was original written as. /// /// This could potentially include disambiguators and backticks. - pub(crate) original_text: String, + crate original_text: String, /// The text to display in the HTML - pub(crate) new_text: String, + crate new_text: String, /// The URL to put in the `href` - pub(crate) href: String, + crate href: String, } /// The attributes on an [`Item`], including attributes like `#[derive(...)]` and `#[inline]`, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 3b926e444034b..d9f6a9d02cab5 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -33,8 +33,8 @@ use crate::passes::{self, Condition::*}; crate use rustc_session::config::{DebuggingOptions, Input, Options}; crate struct ResolverCaches { - pub all_traits: Option>, - pub all_trait_impls: Option>, + crate all_traits: Option>, + crate all_trait_impls: Option>, } crate struct DocContext<'tcx> { diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 8badce8226fd9..c3edefc469864 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -175,7 +175,7 @@ crate struct StylePath { } impl StylePath { - pub fn basename(&self) -> Result { + crate fn basename(&self) -> Result { Ok(try_none!(try_none!(self.path.file_stem(), &self.path).to_str(), &self.path).to_string()) } } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 7dbf00420de12..e82ab122481d4 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -362,7 +362,7 @@ struct DiagnosticInfo<'a> { #[derive(Clone, Debug, Hash)] struct CachedLink { - pub res: (Res, Option), + res: (Res, Option), } struct LinkCollector<'a, 'tcx> {