Skip to content

Commit

Permalink
rustdoc: Make some pub items crate-private
Browse files Browse the repository at this point in the history
They don't need to be `pub`. Making them crate-private improves code
clarity and `dead_code` linting.
  • Loading branch information
camelid committed Jan 22, 2022
1 parent 17d29dc commit fc16b81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/librustdoc/clean/types.rs
Expand Up @@ -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<Symbol>,
kind: ItemKind,
Expand All @@ -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<Symbol>,
kind: ItemKind,
Expand All @@ -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<Symbol>,
kind: ItemKind,
Expand Down Expand Up @@ -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<UrlFragment>,
crate fragment: Option<UrlFragment>,
}

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]`,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/core.rs
Expand Up @@ -33,8 +33,8 @@ use crate::passes::{self, Condition::*};
crate use rustc_session::config::{DebuggingOptions, Input, Options};

crate struct ResolverCaches {
pub all_traits: Option<Vec<DefId>>,
pub all_trait_impls: Option<Vec<DefId>>,
crate all_traits: Option<Vec<DefId>>,
crate all_trait_impls: Option<Vec<DefId>>,
}

crate struct DocContext<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Expand Up @@ -175,7 +175,7 @@ crate struct StylePath {
}

impl StylePath {
pub fn basename(&self) -> Result<String, Error> {
crate fn basename(&self) -> Result<String, Error> {
Ok(try_none!(try_none!(self.path.file_stem(), &self.path).to_str(), &self.path).to_string())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/collect_intra_doc_links.rs
Expand Up @@ -362,7 +362,7 @@ struct DiagnosticInfo<'a> {

#[derive(Clone, Debug, Hash)]
struct CachedLink {
pub res: (Res, Option<UrlFragment>),
res: (Res, Option<UrlFragment>),
}

struct LinkCollector<'a, 'tcx> {
Expand Down

0 comments on commit fc16b81

Please sign in to comment.