diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index a07d6b73f06..ff996b2a925 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -20,13 +20,13 @@ struct RegionDeps<'tcx> { smaller: FxHashSet>, } -pub struct AutoTraitFinder<'a, 'tcx> { - pub cx: &'a core::DocContext<'tcx>, - pub f: auto_trait::AutoTraitFinder<'tcx>, +crate struct AutoTraitFinder<'a, 'tcx> { + crate cx: &'a core::DocContext<'tcx>, + crate f: auto_trait::AutoTraitFinder<'tcx>, } impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { - pub fn new(cx: &'a core::DocContext<'tcx>) -> Self { + crate fn new(cx: &'a core::DocContext<'tcx>) -> Self { let f = auto_trait::AutoTraitFinder::new(cx.tcx); AutoTraitFinder { cx, f } @@ -34,7 +34,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // FIXME(eddyb) figure out a better way to pass information about // parametrization of `ty` than `param_env_def_id`. - pub fn get_auto_trait_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec { + crate fn get_auto_trait_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec { let param_env = self.cx.tcx.param_env(param_env_def_id); debug!("get_auto_trait_impls({:?})", ty); diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index f15142f4983..5721927d0ec 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -9,18 +9,18 @@ use rustc_span::DUMMY_SP; use super::*; -pub struct BlanketImplFinder<'a, 'tcx> { - pub cx: &'a core::DocContext<'tcx>, +crate struct BlanketImplFinder<'a, 'tcx> { + crate cx: &'a core::DocContext<'tcx>, } impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> { - pub fn new(cx: &'a core::DocContext<'tcx>) -> Self { + crate fn new(cx: &'a core::DocContext<'tcx>) -> Self { BlanketImplFinder { cx } } // FIXME(eddyb) figure out a better way to pass information about // parametrization of `ty` than `param_env_def_id`. - pub fn get_blanket_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec { + crate fn get_blanket_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec { let param_env = self.cx.tcx.param_env(param_env_def_id); debug!("get_blanket_impls({:?})", ty); diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index b659f3eab43..2f169d1d3f3 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -20,7 +20,7 @@ use crate::html::escape::Escape; mod tests; #[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub enum Cfg { +crate enum Cfg { /// Accepts all configurations. True, /// Denies all configurations. @@ -36,9 +36,9 @@ pub enum Cfg { } #[derive(PartialEq, Debug)] -pub struct InvalidCfgError { - pub msg: &'static str, - pub span: Span, +crate struct InvalidCfgError { + crate msg: &'static str, + crate span: Span, } impl Cfg { @@ -59,7 +59,7 @@ impl Cfg { /// /// If the content is not properly formatted, it will return an error indicating what and where /// the error is. - pub fn parse(cfg: &MetaItem) -> Result { + crate fn parse(cfg: &MetaItem) -> Result { let name = match cfg.ident() { Some(ident) => ident.name, None => { @@ -102,7 +102,7 @@ impl Cfg { /// /// Equivalent to `attr::cfg_matches`. // FIXME: Actually make use of `features`. - pub fn matches(&self, parse_sess: &ParseSess, features: Option<&Features>) -> bool { + crate fn matches(&self, parse_sess: &ParseSess, features: Option<&Features>) -> bool { match *self { Cfg::False => false, Cfg::True => true, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 56ce0bae8bb..daca4f8a933 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3,11 +3,11 @@ mod auto_trait; mod blanket_impl; -pub mod cfg; -pub mod inline; +crate mod cfg; +crate mod inline; mod simplify; -pub mod types; -pub mod utils; +crate mod types; +crate mod utils; use rustc_ast as ast; use rustc_attr as attr; @@ -39,18 +39,18 @@ use crate::doctree; use utils::*; -pub use utils::{get_auto_trait_and_blanket_impls, krate, register_res}; +crate use utils::{get_auto_trait_and_blanket_impls, krate, register_res}; -pub use self::types::FnRetTy::*; -pub use self::types::ItemKind::*; -pub use self::types::SelfTy::*; -pub use self::types::Type::*; -pub use self::types::Visibility::{Inherited, Public}; -pub use self::types::*; +crate use self::types::FnRetTy::*; +crate use self::types::ItemKind::*; +crate use self::types::SelfTy::*; +crate use self::types::Type::*; +crate use self::types::Visibility::{Inherited, Public}; +crate use self::types::*; const FN_OUTPUT_NAME: &str = "Output"; -pub trait Clean { +crate trait Clean { fn clean(&self, cx: &DocContext<'_>) -> T; } diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 990189f6ea0..121c9d2bc4c 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -21,7 +21,7 @@ use crate::clean::GenericArgs as PP; use crate::clean::WherePredicate as WP; use crate::core::DocContext; -pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec) -> Vec { +crate fn where_clauses(cx: &DocContext<'_>, clauses: Vec) -> Vec { // First, partition the where clause into its separate components let mut params: BTreeMap<_, Vec<_>> = BTreeMap::new(); let mut lifetimes = Vec::new(); @@ -74,7 +74,7 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec) -> Vec { clauses } -pub fn merge_bounds( +crate fn merge_bounds( cx: &clean::DocContext<'_>, bounds: &mut Vec, trait_did: DefId, diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3060cf79cd5..aff62667176 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -45,47 +45,47 @@ use self::ItemKind::*; use self::SelfTy::*; use self::Type::*; -thread_local!(pub static MAX_DEF_ID: RefCell> = Default::default()); +thread_local!(crate static MAX_DEF_ID: RefCell> = Default::default()); #[derive(Clone, Debug)] -pub struct Crate { - pub name: String, - pub version: Option, - pub src: FileName, - pub module: Option, - pub externs: Vec<(CrateNum, ExternalCrate)>, - pub primitives: Vec<(DefId, PrimitiveType, Attributes)>, +crate struct Crate { + crate name: String, + crate version: Option, + crate src: FileName, + crate module: Option, + crate externs: Vec<(CrateNum, ExternalCrate)>, + crate primitives: Vec<(DefId, PrimitiveType, Attributes)>, // These are later on moved into `CACHEKEY`, leaving the map empty. // Only here so that they can be filtered through the rustdoc passes. - pub external_traits: Rc>>, - pub masked_crates: FxHashSet, - pub collapsed: bool, + crate external_traits: Rc>>, + crate masked_crates: FxHashSet, + crate collapsed: bool, } #[derive(Clone, Debug)] -pub struct ExternalCrate { - pub name: String, - pub src: FileName, - pub attrs: Attributes, - pub primitives: Vec<(DefId, PrimitiveType, Attributes)>, - pub keywords: Vec<(DefId, String, Attributes)>, +crate struct ExternalCrate { + crate name: String, + crate src: FileName, + crate attrs: Attributes, + crate primitives: Vec<(DefId, PrimitiveType, Attributes)>, + crate keywords: Vec<(DefId, String, Attributes)>, } /// Anything with a source location and set of attributes and, optionally, a /// name. That is, anything that can be documented. This doesn't correspond /// directly to the AST's concept of an item; it's a strict superset. #[derive(Clone)] -pub struct Item { +crate struct Item { /// Stringified span - pub source: Span, + crate source: Span, /// Not everything has a name. E.g., impls - pub name: Option, - pub attrs: Attributes, - pub kind: ItemKind, - pub visibility: Visibility, - pub def_id: DefId, - pub stability: Option, - pub deprecation: Option, + crate name: Option, + crate attrs: Attributes, + crate visibility: Visibility, + crate kind: ItemKind, + crate def_id: DefId, + crate stability: Option, + crate deprecation: Option, } impl fmt::Debug for Item { @@ -108,80 +108,80 @@ impl fmt::Debug for Item { impl Item { /// Finds the `doc` attribute as a NameValue and returns the corresponding /// value found. - pub fn doc_value(&self) -> Option<&str> { + crate fn doc_value(&self) -> Option<&str> { self.attrs.doc_value() } /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined /// with newlines. - pub fn collapsed_doc_value(&self) -> Option { + crate fn collapsed_doc_value(&self) -> Option { self.attrs.collapsed_doc_value() } - pub fn links(&self) -> Vec { + crate fn links(&self) -> Vec { self.attrs.links(&self.def_id.krate) } - pub fn is_crate(&self) -> bool { + crate fn is_crate(&self) -> bool { match self.kind { StrippedItem(box ModuleItem(Module { is_crate: true, .. })) | ModuleItem(Module { is_crate: true, .. }) => true, _ => false, } } - pub fn is_mod(&self) -> bool { + crate fn is_mod(&self) -> bool { self.type_() == ItemType::Module } - pub fn is_trait(&self) -> bool { + crate fn is_trait(&self) -> bool { self.type_() == ItemType::Trait } - pub fn is_struct(&self) -> bool { + crate fn is_struct(&self) -> bool { self.type_() == ItemType::Struct } - pub fn is_enum(&self) -> bool { + crate fn is_enum(&self) -> bool { self.type_() == ItemType::Enum } - pub fn is_variant(&self) -> bool { + crate fn is_variant(&self) -> bool { self.type_() == ItemType::Variant } - pub fn is_associated_type(&self) -> bool { + crate fn is_associated_type(&self) -> bool { self.type_() == ItemType::AssocType } - pub fn is_associated_const(&self) -> bool { + crate fn is_associated_const(&self) -> bool { self.type_() == ItemType::AssocConst } - pub fn is_method(&self) -> bool { + crate fn is_method(&self) -> bool { self.type_() == ItemType::Method } - pub fn is_ty_method(&self) -> bool { + crate fn is_ty_method(&self) -> bool { self.type_() == ItemType::TyMethod } - pub fn is_typedef(&self) -> bool { + crate fn is_typedef(&self) -> bool { self.type_() == ItemType::Typedef } - pub fn is_primitive(&self) -> bool { + crate fn is_primitive(&self) -> bool { self.type_() == ItemType::Primitive } - pub fn is_union(&self) -> bool { + crate fn is_union(&self) -> bool { self.type_() == ItemType::Union } - pub fn is_import(&self) -> bool { + crate fn is_import(&self) -> bool { self.type_() == ItemType::Import } - pub fn is_extern_crate(&self) -> bool { + crate fn is_extern_crate(&self) -> bool { self.type_() == ItemType::ExternCrate } - pub fn is_keyword(&self) -> bool { + crate fn is_keyword(&self) -> bool { self.type_() == ItemType::Keyword } - pub fn is_stripped(&self) -> bool { + crate fn is_stripped(&self) -> bool { match self.kind { StrippedItem(..) => true, ImportItem(ref i) => !i.should_be_displayed, _ => false, } } - pub fn has_stripped_fields(&self) -> Option { + crate fn has_stripped_fields(&self) -> Option { match self.kind { StructItem(ref _struct) => Some(_struct.fields_stripped), UnionItem(ref union) => Some(union.fields_stripped), @@ -192,7 +192,7 @@ impl Item { } } - pub fn stability_class(&self) -> Option { + crate fn stability_class(&self) -> Option { self.stability.as_ref().and_then(|ref s| { let mut classes = Vec::with_capacity(2); @@ -209,23 +209,23 @@ impl Item { }) } - pub fn stable_since(&self) -> Option { + crate fn stable_since(&self) -> Option { match self.stability?.level { StabilityLevel::Stable { since, .. } => Some(since.as_str()), StabilityLevel::Unstable { .. } => None, } } - pub fn is_non_exhaustive(&self) -> bool { + crate fn is_non_exhaustive(&self) -> bool { self.attrs.other_attrs.iter().any(|a| a.has_name(sym::non_exhaustive)) } /// Returns a documentation-level item type from the item. - pub fn type_(&self) -> ItemType { + crate fn type_(&self) -> ItemType { ItemType::from(self) } - pub fn is_default(&self) -> bool { + crate fn is_default(&self) -> bool { match self.kind { ItemKind::MethodItem(ref meth) => { if let Some(defaultness) = meth.defaultness { @@ -239,7 +239,7 @@ impl Item { } /// See comments on next_def_id - pub fn is_fake(&self) -> bool { + crate fn is_fake(&self) -> bool { MAX_DEF_ID.with(|m| { m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false) }) @@ -247,7 +247,7 @@ impl Item { } #[derive(Clone, Debug)] -pub enum ItemKind { +crate enum ItemKind { ExternCrateItem(String, Option), ImportItem(Import), StructItem(Struct), @@ -286,14 +286,14 @@ pub enum ItemKind { } impl ItemKind { - pub fn is_type_alias(&self) -> bool { + crate fn is_type_alias(&self) -> bool { match *self { ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true, _ => false, } } - pub fn as_assoc_kind(&self) -> Option { + crate fn as_assoc_kind(&self) -> Option { match *self { ItemKind::AssocConstItem(..) => Some(AssocKind::Const), ItemKind::AssocTypeItem(..) => Some(AssocKind::Type), @@ -304,12 +304,12 @@ impl ItemKind { } #[derive(Clone, Debug)] -pub struct Module { - pub items: Vec, - pub is_crate: bool, +crate struct Module { + crate items: Vec, + crate is_crate: bool, } -pub struct ListAttributesIter<'a> { +crate struct ListAttributesIter<'a> { attrs: slice::Iter<'a, ast::Attribute>, current_list: vec::IntoIter, name: Symbol, @@ -343,7 +343,7 @@ impl<'a> Iterator for ListAttributesIter<'a> { } } -pub trait AttributesExt { +crate trait AttributesExt { /// Finds an attribute as List and returns the list of attributes nested inside. fn lists(&self, name: Symbol) -> ListAttributesIter<'_>; } @@ -354,7 +354,7 @@ impl AttributesExt for [ast::Attribute] { } } -pub trait NestedAttributesExt { +crate trait NestedAttributesExt { /// Returns `true` if the attribute list contains a specific `Word` fn has_word(self, word: Symbol) -> bool; } @@ -374,20 +374,20 @@ impl> NestedAttributesExt for I { /// information can be given when a doctest fails. Sugared doc comments and "raw" doc comments are /// kept separate because of issue #42760. #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct DocFragment { - pub line: usize, - pub span: rustc_span::Span, +crate struct DocFragment { + crate line: usize, + crate span: rustc_span::Span, /// The module this doc-comment came from. /// /// This allows distinguishing between the original documentation and a pub re-export. /// If it is `None`, the item was not re-exported. - pub parent_module: Option, - pub doc: String, - pub kind: DocFragmentKind, + crate parent_module: Option, + crate doc: String, + crate kind: DocFragmentKind, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum DocFragmentKind { +crate enum DocFragmentKind { /// A doc fragment created from a `///` or `//!` doc comment. SugaredDoc, /// A doc fragment created from a "raw" `#[doc=""]` attribute. @@ -413,21 +413,21 @@ impl<'a> FromIterator<&'a DocFragment> for String { } #[derive(Clone, Debug, Default)] -pub struct Attributes { - pub doc_strings: Vec, - pub other_attrs: Vec, - pub cfg: Option>, - pub span: Option, +crate struct Attributes { + crate doc_strings: Vec, + crate other_attrs: Vec, + crate cfg: Option>, + crate span: Option, /// map from Rust paths to resolved defs and potential URL fragments - pub links: Vec, - pub inner_docs: bool, + crate links: Vec, + crate inner_docs: bool, } #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] /// A link that has not yet been rendered. /// /// This link will be turned into a rendered link by [`Attributes::links`] -pub struct ItemLink { +crate struct ItemLink { /// The original link written in the markdown pub(crate) link: String, /// The link text displayed in the HTML. @@ -440,7 +440,7 @@ pub struct ItemLink { pub(crate) fragment: Option, } -pub struct RenderedLink { +crate struct RenderedLink { /// The text the link was original written as. /// /// This could potentially include disambiguators and backticks. @@ -453,7 +453,7 @@ pub struct RenderedLink { impl Attributes { /// Extracts the content from an attribute `#[doc(cfg(content))]`. - pub fn extract_cfg(mi: &ast::MetaItem) -> Option<&ast::MetaItem> { + crate fn extract_cfg(mi: &ast::MetaItem) -> Option<&ast::MetaItem> { use rustc_ast::NestedMetaItem::MetaItem; if let ast::MetaItemKind::List(ref nmis) = mi.kind { @@ -478,7 +478,7 @@ impl Attributes { /// Reads a `MetaItem` from within an attribute, looks for whether it is a /// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from /// its expansion. - pub fn extract_include(mi: &ast::MetaItem) -> Option<(String, String)> { + crate fn extract_include(mi: &ast::MetaItem) -> Option<(String, String)> { mi.meta_item_list().and_then(|list| { for meta in list { if meta.has_name(sym::include) { @@ -514,7 +514,7 @@ impl Attributes { }) } - pub fn has_doc_flag(&self, flag: Symbol) -> bool { + crate fn has_doc_flag(&self, flag: Symbol) -> bool { for attr in &self.other_attrs { if !attr.has_name(sym::doc) { continue; @@ -530,7 +530,7 @@ impl Attributes { false } - pub fn from_ast( + crate fn from_ast( diagnostic: &::rustc_errors::Handler, attrs: &[ast::Attribute], additional_attrs: Option<(&[ast::Attribute], DefId)>, @@ -634,20 +634,20 @@ impl Attributes { /// Finds the `doc` attribute as a NameValue and returns the corresponding /// value found. - pub fn doc_value(&self) -> Option<&str> { + crate fn doc_value(&self) -> Option<&str> { self.doc_strings.first().map(|s| s.doc.as_str()) } /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined /// with newlines. - pub fn collapsed_doc_value(&self) -> Option { + crate fn collapsed_doc_value(&self) -> Option { if !self.doc_strings.is_empty() { Some(self.doc_strings.iter().collect()) } else { None } } /// Gets links as a vector /// /// Cache must be populated before call - pub fn links(&self, krate: &CrateNum) -> Vec { + crate fn links(&self, krate: &CrateNum) -> Vec { use crate::html::format::href; use crate::html::render::CURRENT_DEPTH; @@ -711,7 +711,7 @@ impl Attributes { .collect() } - pub fn get_doc_aliases(&self) -> FxHashSet { + crate fn get_doc_aliases(&self) -> FxHashSet { self.other_attrs .lists(sym::doc) .filter(|a| a.has_name(sym::alias)) @@ -756,13 +756,13 @@ impl AttributesExt for Attributes { } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum GenericBound { +crate enum GenericBound { TraitBound(PolyTrait, hir::TraitBoundModifier), Outlives(Lifetime), } impl GenericBound { - pub fn maybe_sized(cx: &DocContext<'_>) -> GenericBound { + crate fn maybe_sized(cx: &DocContext<'_>) -> GenericBound { let did = cx.tcx.require_lang_item(LangItem::Sized, None); let empty = cx.tcx.intern_substs(&[]); let path = external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty); @@ -776,7 +776,7 @@ impl GenericBound { ) } - pub fn is_sized_bound(&self, cx: &DocContext<'_>) -> bool { + crate fn is_sized_bound(&self, cx: &DocContext<'_>) -> bool { use rustc_hir::TraitBoundModifier as TBM; if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self { if trait_.def_id() == cx.tcx.lang_items().sized_trait() { @@ -786,14 +786,14 @@ impl GenericBound { false } - pub fn get_poly_trait(&self) -> Option { + crate fn get_poly_trait(&self) -> Option { if let GenericBound::TraitBound(ref p, _) = *self { return Some(p.clone()); } None } - pub fn get_trait_type(&self) -> Option { + crate fn get_trait_type(&self) -> Option { if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, _) = *self { Some(trait_.clone()) } else { @@ -803,33 +803,33 @@ impl GenericBound { } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct Lifetime(pub String); +crate struct Lifetime(pub String); impl Lifetime { - pub fn get_ref<'a>(&'a self) -> &'a str { + crate fn get_ref<'a>(&'a self) -> &'a str { let Lifetime(ref s) = *self; let s: &'a str = s; s } - pub fn statik() -> Lifetime { + crate fn statik() -> Lifetime { Lifetime("'static".to_string()) } - pub fn elided() -> Lifetime { + crate fn elided() -> Lifetime { Lifetime("'_".to_string()) } } #[derive(Clone, Debug)] -pub enum WherePredicate { +crate enum WherePredicate { BoundPredicate { ty: Type, bounds: Vec }, RegionPredicate { lifetime: Lifetime, bounds: Vec }, EqPredicate { lhs: Type, rhs: Type }, } impl WherePredicate { - pub fn get_bounds(&self) -> Option<&[GenericBound]> { + crate fn get_bounds(&self) -> Option<&[GenericBound]> { match *self { WherePredicate::BoundPredicate { ref bounds, .. } => Some(bounds), WherePredicate::RegionPredicate { ref bounds, .. } => Some(bounds), @@ -839,7 +839,7 @@ impl WherePredicate { } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum GenericParamDefKind { +crate enum GenericParamDefKind { Lifetime, Type { did: DefId, @@ -854,7 +854,7 @@ pub enum GenericParamDefKind { } impl GenericParamDefKind { - pub fn is_type(&self) -> bool { + crate fn is_type(&self) -> bool { match *self { GenericParamDefKind::Type { .. } => true, _ => false, @@ -864,7 +864,7 @@ impl GenericParamDefKind { // FIXME(eddyb) this either returns the default of a type parameter, or the // type of a `const` parameter. It seems that the intention is to *visit* // any embedded types, but `get_type` seems to be the wrong name for that. - pub fn get_type(&self) -> Option { + crate fn get_type(&self) -> Option { match self { GenericParamDefKind::Type { default, .. } => default.clone(), GenericParamDefKind::Const { ty, .. } => Some(ty.clone()), @@ -874,28 +874,28 @@ impl GenericParamDefKind { } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct GenericParamDef { - pub name: String, - pub kind: GenericParamDefKind, +crate struct GenericParamDef { + crate name: String, + crate kind: GenericParamDefKind, } impl GenericParamDef { - pub fn is_synthetic_type_param(&self) -> bool { + crate fn is_synthetic_type_param(&self) -> bool { match self.kind { GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => false, GenericParamDefKind::Type { ref synthetic, .. } => synthetic.is_some(), } } - pub fn is_type(&self) -> bool { + crate fn is_type(&self) -> bool { self.kind.is_type() } - pub fn get_type(&self) -> Option { + crate fn get_type(&self) -> Option { self.kind.get_type() } - pub fn get_bounds(&self) -> Option<&[GenericBound]> { + crate fn get_bounds(&self) -> Option<&[GenericBound]> { match self.kind { GenericParamDefKind::Type { ref bounds, .. } => Some(bounds), _ => None, @@ -905,49 +905,49 @@ impl GenericParamDef { // maybe use a Generic enum and use Vec? #[derive(Clone, Debug, Default)] -pub struct Generics { - pub params: Vec, - pub where_predicates: Vec, +crate struct Generics { + crate params: Vec, + crate where_predicates: Vec, } #[derive(Clone, Debug)] -pub struct Method { - pub generics: Generics, - pub decl: FnDecl, - pub header: hir::FnHeader, - pub defaultness: Option, - pub all_types: Vec<(Type, TypeKind)>, - pub ret_types: Vec<(Type, TypeKind)>, +crate struct Method { + crate generics: Generics, + crate decl: FnDecl, + crate header: hir::FnHeader, + crate defaultness: Option, + crate all_types: Vec<(Type, TypeKind)>, + crate ret_types: Vec<(Type, TypeKind)>, } #[derive(Clone, Debug)] -pub struct TyMethod { - pub header: hir::FnHeader, - pub decl: FnDecl, - pub generics: Generics, - pub all_types: Vec<(Type, TypeKind)>, - pub ret_types: Vec<(Type, TypeKind)>, +crate struct TyMethod { + crate header: hir::FnHeader, + crate decl: FnDecl, + crate generics: Generics, + crate all_types: Vec<(Type, TypeKind)>, + crate ret_types: Vec<(Type, TypeKind)>, } #[derive(Clone, Debug)] -pub struct Function { - pub decl: FnDecl, - pub generics: Generics, - pub header: hir::FnHeader, - pub all_types: Vec<(Type, TypeKind)>, - pub ret_types: Vec<(Type, TypeKind)>, +crate struct Function { + crate decl: FnDecl, + crate generics: Generics, + crate header: hir::FnHeader, + crate all_types: Vec<(Type, TypeKind)>, + crate ret_types: Vec<(Type, TypeKind)>, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct FnDecl { - pub inputs: Arguments, - pub output: FnRetTy, - pub c_variadic: bool, - pub attrs: Attributes, +crate struct FnDecl { + crate inputs: Arguments, + crate output: FnRetTy, + crate c_variadic: bool, + crate attrs: Attributes, } impl FnDecl { - pub fn self_type(&self) -> Option { + crate fn self_type(&self) -> Option { self.inputs.values.get(0).and_then(|v| v.to_self()) } @@ -960,7 +960,7 @@ impl FnDecl { /// /// This function will panic if the return type does not match the expected sugaring for async /// functions. - pub fn sugared_async_return_type(&self) -> FnRetTy { + crate fn sugared_async_return_type(&self) -> FnRetTy { match &self.output { FnRetTy::Return(Type::ImplTrait(bounds)) => match &bounds[0] { GenericBound::TraitBound(PolyTrait { trait_, .. }, ..) => { @@ -975,25 +975,25 @@ impl FnDecl { } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct Arguments { - pub values: Vec, +crate struct Arguments { + crate values: Vec, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct Argument { - pub type_: Type, - pub name: String, +crate struct Argument { + crate type_: Type, + crate name: String, } #[derive(Clone, PartialEq, Debug)] -pub enum SelfTy { +crate enum SelfTy { SelfValue, SelfBorrowed(Option, Mutability), SelfExplicit(Type), } impl Argument { - pub fn to_self(&self) -> Option { + crate fn to_self(&self) -> Option { if self.name != "self" { return None; } @@ -1010,7 +1010,7 @@ impl Argument { } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum FnRetTy { +crate enum FnRetTy { Return(Type), DefaultReturn, } @@ -1025,34 +1025,34 @@ impl GetDefId for FnRetTy { } #[derive(Clone, Debug)] -pub struct Trait { - pub auto: bool, - pub unsafety: hir::Unsafety, - pub items: Vec, - pub generics: Generics, - pub bounds: Vec, - pub is_spotlight: bool, - pub is_auto: bool, +crate struct Trait { + crate auto: bool, + crate unsafety: hir::Unsafety, + crate items: Vec, + crate generics: Generics, + crate bounds: Vec, + crate is_spotlight: bool, + crate is_auto: bool, } #[derive(Clone, Debug)] -pub struct TraitAlias { - pub generics: Generics, - pub bounds: Vec, +crate struct TraitAlias { + crate generics: Generics, + crate bounds: Vec, } /// A trait reference, which may have higher ranked lifetimes. #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct PolyTrait { - pub trait_: Type, - pub generic_params: Vec, +crate struct PolyTrait { + crate trait_: Type, + crate generic_params: Vec, } /// A representation of a type suitable for hyperlinking purposes. Ideally, one can get the original /// type out of the AST/`TyCtxt` given one of these, if more information is needed. Most /// importantly, it does not preserve mutability or boxes. #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum Type { +crate enum Type { /// Structs/enums/traits (most that would be an `hir::TyKind::Path`). ResolvedPath { path: Path, @@ -1095,7 +1095,7 @@ pub enum Type { } #[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)] -pub enum PrimitiveType { +crate enum PrimitiveType { Isize, I8, I16, @@ -1124,7 +1124,7 @@ pub enum PrimitiveType { } #[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)] -pub enum TypeKind { +crate enum TypeKind { Enum, Function, Module, @@ -1141,7 +1141,7 @@ pub enum TypeKind { TraitAlias, } -pub trait GetDefId { +crate trait GetDefId { fn def_id(&self) -> Option; } @@ -1152,7 +1152,7 @@ impl GetDefId for Option { } impl Type { - pub fn primitive_type(&self) -> Option { + crate fn primitive_type(&self) -> Option { match *self { Primitive(p) | BorrowedRef { type_: box Primitive(p), .. } => Some(p), Slice(..) | BorrowedRef { type_: box Slice(..), .. } => Some(PrimitiveType::Slice), @@ -1172,21 +1172,21 @@ impl Type { } } - pub fn is_generic(&self) -> bool { + crate fn is_generic(&self) -> bool { match *self { ResolvedPath { is_generic, .. } => is_generic, _ => false, } } - pub fn is_self_type(&self) -> bool { + crate fn is_self_type(&self) -> bool { match *self { Generic(ref name) => name == "Self", _ => false, } } - pub fn generics(&self) -> Option> { + crate fn generics(&self) -> Option> { match *self { ResolvedPath { ref path, .. } => path.segments.last().and_then(|seg| { if let GenericArgs::AngleBracketed { ref args, .. } = seg.args { @@ -1206,7 +1206,7 @@ impl Type { } } - pub fn bindings(&self) -> Option<&[TypeBinding]> { + crate fn bindings(&self) -> Option<&[TypeBinding]> { match *self { ResolvedPath { ref path, .. } => path.segments.last().and_then(|seg| { if let GenericArgs::AngleBracketed { ref bindings, .. } = seg.args { @@ -1219,14 +1219,14 @@ impl Type { } } - pub fn is_full_generic(&self) -> bool { + crate fn is_full_generic(&self) -> bool { match *self { Type::Generic(_) => true, _ => false, } } - pub fn projection(&self) -> Option<(&Type, DefId, &str)> { + crate fn projection(&self) -> Option<(&Type, DefId, &str)> { let (self_, trait_, name) = match self { QPath { ref self_type, ref trait_, ref name } => (self_type, trait_, name), _ => return None, @@ -1267,7 +1267,7 @@ impl GetDefId for Type { } impl PrimitiveType { - pub fn from_hir(prim: hir::PrimTy) -> PrimitiveType { + crate fn from_hir(prim: hir::PrimTy) -> PrimitiveType { match prim { hir::PrimTy::Int(IntTy::Isize) => PrimitiveType::Isize, hir::PrimTy::Int(IntTy::I8) => PrimitiveType::I8, @@ -1289,7 +1289,7 @@ impl PrimitiveType { } } - pub fn from_symbol(s: Symbol) -> Option { + crate fn from_symbol(s: Symbol) -> Option { match s { sym::isize => Some(PrimitiveType::Isize), sym::i8 => Some(PrimitiveType::I8), @@ -1320,7 +1320,7 @@ impl PrimitiveType { } } - pub fn as_str(&self) -> &'static str { + crate fn as_str(&self) -> &'static str { use self::PrimitiveType::*; match *self { Isize => "isize", @@ -1351,11 +1351,11 @@ impl PrimitiveType { } } - pub fn impls(&self, tcx: TyCtxt<'_>) -> &'static SmallVec<[DefId; 4]> { + crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static SmallVec<[DefId; 4]> { Self::all_impls(tcx).get(self).expect("missing impl for primitive type") } - pub fn all_impls(tcx: TyCtxt<'_>) -> &'static FxHashMap> { + crate fn all_impls(tcx: TyCtxt<'_>) -> &'static FxHashMap> { static CELL: OnceCell>> = OnceCell::new(); CELL.get_or_init(move || { @@ -1431,7 +1431,7 @@ impl PrimitiveType { }) } - pub fn to_url_str(&self) -> &'static str { + crate fn to_url_str(&self) -> &'static str { self.as_str() } } @@ -1485,7 +1485,7 @@ impl From for PrimitiveType { } #[derive(Clone, PartialEq, Eq, Debug)] -pub enum Visibility { +crate enum Visibility { Public, Inherited, Crate, @@ -1493,63 +1493,63 @@ pub enum Visibility { } #[derive(Clone, Debug)] -pub struct Struct { - pub struct_type: doctree::StructType, - pub generics: Generics, - pub fields: Vec, - pub fields_stripped: bool, +crate struct Struct { + crate struct_type: doctree::StructType, + crate generics: Generics, + crate fields: Vec, + crate fields_stripped: bool, } #[derive(Clone, Debug)] -pub struct Union { - pub struct_type: doctree::StructType, - pub generics: Generics, - pub fields: Vec, - pub fields_stripped: bool, +crate struct Union { + crate struct_type: doctree::StructType, + crate generics: Generics, + crate fields: Vec, + crate fields_stripped: bool, } /// This is a more limited form of the standard Struct, different in that /// it lacks the things most items have (name, id, parameterization). Found /// only as a variant in an enum. #[derive(Clone, Debug)] -pub struct VariantStruct { - pub struct_type: doctree::StructType, - pub fields: Vec, - pub fields_stripped: bool, +crate struct VariantStruct { + crate struct_type: doctree::StructType, + crate fields: Vec, + crate fields_stripped: bool, } #[derive(Clone, Debug)] -pub struct Enum { - pub variants: IndexVec, - pub generics: Generics, - pub variants_stripped: bool, +crate struct Enum { + crate variants: IndexVec, + crate generics: Generics, + crate variants_stripped: bool, } #[derive(Clone, Debug)] -pub struct Variant { - pub kind: VariantKind, +crate struct Variant { + crate kind: VariantKind, } #[derive(Clone, Debug)] -pub enum VariantKind { +crate enum VariantKind { CLike, Tuple(Vec), Struct(VariantStruct), } #[derive(Clone, Debug)] -pub struct Span { - pub filename: FileName, - pub cnum: CrateNum, - pub loline: usize, - pub locol: usize, - pub hiline: usize, - pub hicol: usize, - pub original: rustc_span::Span, +crate struct Span { + crate filename: FileName, + crate cnum: CrateNum, + crate loline: usize, + crate locol: usize, + crate hiline: usize, + crate hicol: usize, + crate original: rustc_span::Span, } impl Span { - pub fn empty() -> Span { + crate fn empty() -> Span { Span { filename: FileName::Anon(0), cnum: LOCAL_CRATE, @@ -1561,49 +1561,49 @@ impl Span { } } - pub fn span(&self) -> rustc_span::Span { + crate fn span(&self) -> rustc_span::Span { self.original } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct Path { - pub global: bool, - pub res: Res, - pub segments: Vec, +crate struct Path { + crate global: bool, + crate res: Res, + crate segments: Vec, } impl Path { - pub fn last_name(&self) -> &str { + crate fn last_name(&self) -> &str { self.segments.last().expect("segments were empty").name.as_str() } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum GenericArg { +crate enum GenericArg { Lifetime(Lifetime), Type(Type), Const(Constant), } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum GenericArgs { +crate enum GenericArgs { AngleBracketed { args: Vec, bindings: Vec }, Parenthesized { inputs: Vec, output: Option }, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct PathSegment { - pub name: String, - pub args: GenericArgs, +crate struct PathSegment { + crate name: String, + crate args: GenericArgs, } #[derive(Clone, Debug)] -pub struct Typedef { - pub type_: Type, - pub generics: Generics, +crate struct Typedef { + crate type_: Type, + crate generics: Generics, // Type of target item. - pub item_type: Option, + crate item_type: Option, } impl GetDefId for Typedef { @@ -1613,75 +1613,75 @@ impl GetDefId for Typedef { } #[derive(Clone, Debug)] -pub struct OpaqueTy { - pub bounds: Vec, - pub generics: Generics, +crate struct OpaqueTy { + crate bounds: Vec, + crate generics: Generics, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct BareFunctionDecl { - pub unsafety: hir::Unsafety, - pub generic_params: Vec, - pub decl: FnDecl, - pub abi: Abi, +crate struct BareFunctionDecl { + crate unsafety: hir::Unsafety, + crate generic_params: Vec, + crate decl: FnDecl, + crate abi: Abi, } #[derive(Clone, Debug)] -pub struct Static { - pub type_: Type, - pub mutability: Mutability, +crate struct Static { + crate type_: Type, + crate mutability: Mutability, /// It's useful to have the value of a static documented, but I have no /// desire to represent expressions (that'd basically be all of the AST, /// which is huge!). So, have a string. - pub expr: String, + crate expr: String, } #[derive(Clone, PartialEq, Eq, Hash, Debug)] -pub struct Constant { - pub type_: Type, - pub expr: String, - pub value: Option, - pub is_literal: bool, +crate struct Constant { + crate type_: Type, + crate expr: String, + crate value: Option, + crate is_literal: bool, } #[derive(Clone, PartialEq, Debug)] -pub enum ImplPolarity { +crate enum ImplPolarity { Positive, Negative, } #[derive(Clone, Debug)] -pub struct Impl { - pub unsafety: hir::Unsafety, - pub generics: Generics, - pub provided_trait_methods: FxHashSet, - pub trait_: Option, - pub for_: Type, - pub items: Vec, - pub polarity: Option, - pub synthetic: bool, - pub blanket_impl: Option, +crate struct Impl { + crate unsafety: hir::Unsafety, + crate generics: Generics, + crate provided_trait_methods: FxHashSet, + crate trait_: Option, + crate for_: Type, + crate items: Vec, + crate polarity: Option, + crate synthetic: bool, + crate blanket_impl: Option, } #[derive(Clone, Debug)] -pub struct Import { - pub kind: ImportKind, - pub source: ImportSource, - pub should_be_displayed: bool, +crate struct Import { + crate kind: ImportKind, + crate source: ImportSource, + crate should_be_displayed: bool, } impl Import { - pub fn new_simple(name: String, source: ImportSource, should_be_displayed: bool) -> Self { + crate fn new_simple(name: String, source: ImportSource, should_be_displayed: bool) -> Self { Self { kind: ImportKind::Simple(name), source, should_be_displayed } } - pub fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self { + crate fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self { Self { kind: ImportKind::Glob, source, should_be_displayed } } } #[derive(Clone, Debug)] -pub enum ImportKind { +crate enum ImportKind { // use source as str; Simple(String), // use source::*; @@ -1689,46 +1689,46 @@ pub enum ImportKind { } #[derive(Clone, Debug)] -pub struct ImportSource { - pub path: Path, - pub did: Option, +crate struct ImportSource { + crate path: Path, + crate did: Option, } #[derive(Clone, Debug)] -pub struct Macro { - pub source: String, - pub imported_from: Option, +crate struct Macro { + crate source: String, + crate imported_from: Option, } #[derive(Clone, Debug)] -pub struct ProcMacro { - pub kind: MacroKind, - pub helpers: Vec, +crate struct ProcMacro { + crate kind: MacroKind, + crate helpers: Vec, } #[derive(Clone, Debug)] -pub struct Deprecation { - pub since: Option, - pub note: Option, - pub is_since_rustc_version: bool, +crate struct Deprecation { + crate since: Option, + crate note: Option, + crate is_since_rustc_version: bool, } /// An type binding on an associated type (e.g., `A = Bar` in `Foo` or /// `A: Send + Sync` in `Foo`). #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct TypeBinding { - pub name: String, - pub kind: TypeBindingKind, +crate struct TypeBinding { + crate name: String, + crate kind: TypeBindingKind, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub enum TypeBindingKind { +crate enum TypeBindingKind { Equality { ty: Type }, Constraint { bounds: Vec }, } impl TypeBinding { - pub fn ty(&self) -> &Type { + crate fn ty(&self) -> &Type { match self.kind { TypeBindingKind::Equality { ref ty } => ty, _ => panic!("expected equality type binding for parenthesized generic args"), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index e5fb656cbb9..22917fbceb4 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -20,7 +20,7 @@ use rustc_middle::ty::{self, DefIdTree, Ty}; use rustc_span::symbol::{kw, sym, Symbol}; use std::mem; -pub fn krate(mut cx: &mut DocContext<'_>) -> Crate { +crate fn krate(mut cx: &mut DocContext<'_>) -> Crate { use crate::visit_lib::LibEmbargoVisitor; let krate = cx.tcx.hir().krate(); @@ -102,11 +102,11 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate { } // extract the stability index for a node from tcx, if possible -pub fn get_stability(cx: &DocContext<'_>, def_id: DefId) -> Option { +crate fn get_stability(cx: &DocContext<'_>, def_id: DefId) -> Option { cx.tcx.lookup_stability(def_id).cloned() } -pub fn get_deprecation(cx: &DocContext<'_>, def_id: DefId) -> Option { +crate fn get_deprecation(cx: &DocContext<'_>, def_id: DefId) -> Option { cx.tcx.lookup_deprecation(def_id).clean(cx) } @@ -183,7 +183,7 @@ pub(super) fn external_path( /// i.e. `[T, U]` when you have the following bounds: `T: Display, U: Option` will return /// `[Display, Option]` (we just returns the list of the types, we don't care about the /// wrapped types in here). -pub fn get_real_types( +crate fn get_real_types( generics: &Generics, arg: &Type, cx: &DocContext<'_>, @@ -261,7 +261,7 @@ pub fn get_real_types( /// /// i.e. `fn foo>(x: u32, y: B)` will return /// `[u32, Display, Option]`. -pub fn get_all_types( +crate fn get_all_types( generics: &Generics, decl: &FnDecl, cx: &DocContext<'_>, @@ -296,7 +296,7 @@ pub fn get_all_types( (all_types.into_iter().collect(), ret_types) } -pub fn strip_type(ty: Type) -> Type { +crate fn strip_type(ty: Type) -> Type { match ty { Type::ResolvedPath { path, param_names, did, is_generic } => { Type::ResolvedPath { path: strip_path(&path), param_names, did, is_generic } @@ -319,7 +319,7 @@ pub fn strip_type(ty: Type) -> Type { } } -pub fn strip_path(path: &Path) -> Path { +crate fn strip_path(path: &Path) -> Path { let segments = path .segments .iter() @@ -332,7 +332,7 @@ pub fn strip_path(path: &Path) -> Path { Path { global: path.global, res: path.res, segments } } -pub fn qpath_to_string(p: &hir::QPath<'_>) -> String { +crate fn qpath_to_string(p: &hir::QPath<'_>) -> String { let segments = match *p { hir::QPath::Resolved(_, ref path) => &path.segments, hir::QPath::TypeRelative(_, ref segment) => return segment.ident.to_string(), @@ -351,7 +351,7 @@ pub fn qpath_to_string(p: &hir::QPath<'_>) -> String { s } -pub fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut Vec) { +crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut Vec) { let tcx = cx.tcx; for item in items { @@ -378,7 +378,7 @@ pub fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut V } } -pub trait ToSource { +crate trait ToSource { fn to_src(&self, cx: &DocContext<'_>) -> String; } @@ -394,7 +394,7 @@ impl ToSource for rustc_span::Span { } } -pub fn name_from_pat(p: &hir::Pat<'_>) -> String { +crate fn name_from_pat(p: &hir::Pat<'_>) -> String { use rustc_hir::*; debug!("trying to get a name from pattern: {:?}", p); @@ -440,7 +440,7 @@ pub fn name_from_pat(p: &hir::Pat<'_>) -> String { } } -pub fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String { +crate fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String { match n.val { ty::ConstKind::Unevaluated(def, _, promoted) => { let mut s = if let Some(def) = def.as_local() { @@ -470,7 +470,7 @@ pub fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String { } } -pub fn print_evaluated_const(cx: &DocContext<'_>, def_id: DefId) -> Option { +crate fn print_evaluated_const(cx: &DocContext<'_>, def_id: DefId) -> Option { cx.tcx.const_eval_poly(def_id).ok().and_then(|val| { let ty = cx.tcx.type_of(def_id); match (val, ty.kind()) { @@ -518,7 +518,7 @@ fn print_const_with_custom_print_scalar(cx: &DocContext<'_>, ct: &'tcx ty::Const } } -pub fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool { +crate fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool { if let hir::Node::Expr(expr) = cx.tcx.hir().get(hir_id) { if let hir::ExprKind::Lit(_) = &expr.kind { return true; @@ -534,7 +534,7 @@ pub fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool { false } -pub fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String { +crate fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String { let value = &cx.tcx.hir().body(body).value; let snippet = if !value.span.from_expansion() { @@ -547,7 +547,7 @@ pub fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String { } /// Given a type Path, resolve it to a Type using the TyCtxt -pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type { +crate fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type { debug!("resolve_type({:?},{:?})", path, id); let is_generic = match path.res { @@ -565,7 +565,7 @@ pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type { ResolvedPath { path, param_names: None, did, is_generic } } -pub fn get_auto_trait_and_blanket_impls( +crate fn get_auto_trait_and_blanket_impls( cx: &DocContext<'tcx>, ty: Ty<'tcx>, param_env_def_id: DefId, @@ -576,7 +576,7 @@ pub fn get_auto_trait_and_blanket_impls( .chain(BlanketImplFinder::new(cx).get_blanket_impls(ty, param_env_def_id)) } -pub fn register_res(cx: &DocContext<'_>, res: Res) -> DefId { +crate fn register_res(cx: &DocContext<'_>, res: Res) -> DefId { debug!("register_res({:?})", res); let (did, kind) = match res { @@ -616,14 +616,14 @@ pub fn register_res(cx: &DocContext<'_>, res: Res) -> DefId { did } -pub fn resolve_use_source(cx: &DocContext<'_>, path: Path) -> ImportSource { +crate fn resolve_use_source(cx: &DocContext<'_>, path: Path) -> ImportSource { ImportSource { did: if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) }, path, } } -pub fn enter_impl_trait(cx: &DocContext<'_>, f: F) -> R +crate fn enter_impl_trait(cx: &DocContext<'_>, f: F) -> R where F: FnOnce() -> R, { diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index f0fc0dc6514..e60970af0d3 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -30,13 +30,13 @@ use crate::passes::{self, Condition, DefaultPassOption}; use crate::theme; #[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum OutputFormat { +crate enum OutputFormat { Json, Html, } impl OutputFormat { - pub fn is_json(&self) -> bool { + crate fn is_json(&self) -> bool { match self { OutputFormat::Json => true, _ => false, @@ -58,96 +58,96 @@ impl TryFrom<&str> for OutputFormat { /// Configuration options for rustdoc. #[derive(Clone)] -pub struct Options { +crate struct Options { // Basic options / Options passed directly to rustc /// The crate root or Markdown file to load. - pub input: PathBuf, + crate input: PathBuf, /// The name of the crate being documented. - pub crate_name: Option, + crate crate_name: Option, /// Whether or not this is a proc-macro crate - pub proc_macro_crate: bool, + crate proc_macro_crate: bool, /// How to format errors and warnings. - pub error_format: ErrorOutputType, + crate error_format: ErrorOutputType, /// Library search paths to hand to the compiler. - pub libs: Vec, + crate libs: Vec, /// Library search paths strings to hand to the compiler. - pub lib_strs: Vec, + crate lib_strs: Vec, /// The list of external crates to link against. - pub externs: Externs, + crate externs: Externs, /// The list of external crates strings to link against. - pub extern_strs: Vec, + crate extern_strs: Vec, /// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`. - pub cfgs: Vec, + crate cfgs: Vec, /// Codegen options to hand to the compiler. - pub codegen_options: CodegenOptions, + crate codegen_options: CodegenOptions, /// Codegen options strings to hand to the compiler. - pub codegen_options_strs: Vec, + crate codegen_options_strs: Vec, /// Debugging (`-Z`) options to pass to the compiler. - pub debugging_opts: DebuggingOptions, + crate debugging_opts: DebuggingOptions, /// Debugging (`-Z`) options strings to pass to the compiler. - pub debugging_opts_strs: Vec, + crate debugging_opts_strs: Vec, /// The target used to compile the crate against. - pub target: TargetTriple, + crate target: TargetTriple, /// Edition used when reading the crate. Defaults to "2015". Also used by default when /// compiling doctests from the crate. - pub edition: Edition, + crate edition: Edition, /// The path to the sysroot. Used during the compilation process. - pub maybe_sysroot: Option, + crate maybe_sysroot: Option, /// Lint information passed over the command-line. - pub lint_opts: Vec<(String, Level)>, + crate lint_opts: Vec<(String, Level)>, /// Whether to ask rustc to describe the lints it knows. Practically speaking, this will not be /// used, since we abort if we have no input file, but it's included for completeness. - pub describe_lints: bool, + crate describe_lints: bool, /// What level to cap lints at. - pub lint_cap: Option, + crate lint_cap: Option, // Options specific to running doctests /// Whether we should run doctests instead of generating docs. - pub should_test: bool, + crate should_test: bool, /// List of arguments to pass to the test harness, if running tests. - pub test_args: Vec, + crate test_args: Vec, /// Optional path to persist the doctest executables to, defaults to a /// temporary directory if not set. - pub persist_doctests: Option, + crate persist_doctests: Option, /// Runtool to run doctests with - pub runtool: Option, + crate runtool: Option, /// Arguments to pass to the runtool - pub runtool_args: Vec, + crate runtool_args: Vec, /// Whether to allow ignoring doctests on a per-target basis /// For example, using ignore-foo to ignore running the doctest on any target that /// contains "foo" as a substring - pub enable_per_target_ignores: bool, + crate enable_per_target_ignores: bool, /// The path to a rustc-like binary to build tests with. If not set, we /// default to loading from $sysroot/bin/rustc. - pub test_builder: Option, + crate test_builder: Option, // Options that affect the documentation process /// The selected default set of passes to use. /// /// Be aware: This option can come both from the CLI and from crate attributes! - pub default_passes: DefaultPassOption, + crate default_passes: DefaultPassOption, /// Any passes manually selected by the user. /// /// Be aware: This option can come both from the CLI and from crate attributes! - pub manual_passes: Vec, + crate manual_passes: Vec, /// Whether to display warnings during doc generation or while gathering doctests. By default, /// all non-rustdoc-specific lints are allowed when generating docs. - pub display_warnings: bool, + crate display_warnings: bool, /// Whether to run the `calculate-doc-coverage` pass, which counts the number of public items /// with and without documentation. - pub show_coverage: bool, + crate show_coverage: bool, // Options that alter generated documentation pages /// Crate version to note on the sidebar of generated docs. - pub crate_version: Option, + crate crate_version: Option, /// Collected options specific to outputting final pages. - pub render_options: RenderOptions, + crate render_options: RenderOptions, /// Output format rendering (used only for "show-coverage" option for the moment) - pub output_format: Option, + crate output_format: Option, /// If this option is set to `true`, rustdoc will only run checks and not generate /// documentation. - pub run_check: bool, + crate run_check: bool, } impl fmt::Debug for Options { @@ -195,89 +195,89 @@ impl fmt::Debug for Options { /// Configuration options for the HTML page-creation process. #[derive(Clone, Debug)] -pub struct RenderOptions { +crate struct RenderOptions { /// Output directory to generate docs into. Defaults to `doc`. - pub output: PathBuf, + crate output: PathBuf, /// External files to insert into generated pages. - pub external_html: ExternalHtml, + crate external_html: ExternalHtml, /// A pre-populated `IdMap` with the default headings and any headings added by Markdown files /// processed by `external_html`. - pub id_map: IdMap, + crate id_map: IdMap, /// If present, playground URL to use in the "Run" button added to code samples. /// /// Be aware: This option can come both from the CLI and from crate attributes! - pub playground_url: Option, + crate playground_url: Option, /// Whether to sort modules alphabetically on a module page instead of using declaration order. /// `true` by default. // // FIXME(misdreavus): the flag name is `--sort-modules-by-appearance` but the meaning is // inverted once read. - pub sort_modules_alphabetically: bool, + crate sort_modules_alphabetically: bool, /// List of themes to extend the docs with. Original argument name is included to assist in /// displaying errors if it fails a theme check. - pub themes: Vec, + crate themes: Vec, /// If present, CSS file that contains rules to add to the default CSS. - pub extension_css: Option, + crate extension_css: Option, /// A map of crate names to the URL to use instead of querying the crate's `html_root_url`. - pub extern_html_root_urls: BTreeMap, + crate extern_html_root_urls: BTreeMap, /// A map of the default settings (values are as for DOM storage API). Keys should lack the /// `rustdoc-` prefix. - pub default_settings: HashMap, + crate default_settings: HashMap, /// If present, suffix added to CSS/JavaScript files when referencing them in generated pages. - pub resource_suffix: String, + crate resource_suffix: String, /// Whether to run the static CSS/JavaScript through a minifier when outputting them. `true` by /// default. // // FIXME(misdreavus): the flag name is `--disable-minification` but the meaning is inverted // once read. - pub enable_minification: bool, + crate enable_minification: bool, /// Whether to create an index page in the root of the output directory. If this is true but /// `enable_index_page` is None, generate a static listing of crates instead. - pub enable_index_page: bool, + crate enable_index_page: bool, /// A file to use as the index page at the root of the output directory. Overrides /// `enable_index_page` to be true if set. - pub index_page: Option, + crate index_page: Option, /// An optional path to use as the location of static files. If not set, uses combinations of /// `../` to reach the documentation root. - pub static_root_path: Option, + crate static_root_path: Option, // Options specific to reading standalone Markdown files /// Whether to generate a table of contents on the output file when reading a standalone /// Markdown file. - pub markdown_no_toc: bool, + crate markdown_no_toc: bool, /// Additional CSS files to link in pages generated from standalone Markdown files. - pub markdown_css: Vec, + crate markdown_css: Vec, /// If present, playground URL to use in the "Run" button added to code samples generated from /// standalone Markdown files. If not present, `playground_url` is used. - pub markdown_playground_url: Option, + crate markdown_playground_url: Option, /// If false, the `select` element to have search filtering by crates on rendered docs /// won't be generated. - pub generate_search_filter: bool, + crate generate_search_filter: bool, /// Document items that have lower than `pub` visibility. - pub document_private: bool, + crate document_private: bool, /// Document items that have `doc(hidden)`. - pub document_hidden: bool, - pub unstable_features: rustc_feature::UnstableFeatures, + crate document_hidden: bool, + crate unstable_features: rustc_feature::UnstableFeatures, } /// Temporary storage for data obtained during `RustdocVisitor::clean()`. /// Later on moved into `CACHE_KEY`. #[derive(Default, Clone)] -pub struct RenderInfo { - pub inlined: FxHashSet, - pub external_paths: crate::core::ExternalPaths, - pub exact_paths: FxHashMap>, - pub access_levels: AccessLevels, - pub deref_trait_did: Option, - pub deref_mut_trait_did: Option, - pub owned_box_did: Option, - pub output_format: Option, +crate struct RenderInfo { + crate inlined: FxHashSet, + crate external_paths: crate::core::ExternalPaths, + crate exact_paths: FxHashMap>, + crate access_levels: AccessLevels, + crate deref_trait_did: Option, + crate deref_mut_trait_did: Option, + crate owned_box_did: Option, + crate output_format: Option, } impl Options { /// Parses the given command-line for options. If an error message or other early-return has /// been printed, returns `Err` with the exit code. - pub fn from_matches(matches: &getopts::Matches) -> Result { + crate fn from_matches(matches: &getopts::Matches) -> Result { // Check for unstable options. nightly_options::check_nightly_options(&matches, &opts()); @@ -656,7 +656,7 @@ impl Options { } /// Returns `true` if the file given as `self.input` is a Markdown file. - pub fn markdown_input(&self) -> bool { + crate fn markdown_input(&self) -> bool { self.input.extension().map_or(false, |e| e == "md" || e == "markdown") } } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 14a2def1383..7d73f3f356b 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -36,52 +36,52 @@ use crate::config::{Options as RustdocOptions, RenderOptions}; use crate::config::{OutputFormat, RenderInfo}; use crate::passes::{self, Condition::*, ConditionalPass}; -pub use rustc_session::config::{CodegenOptions, DebuggingOptions, Input, Options}; -pub use rustc_session::search_paths::SearchPath; +crate use rustc_session::config::{CodegenOptions, DebuggingOptions, Input, Options}; +crate use rustc_session::search_paths::SearchPath; -pub type ExternalPaths = FxHashMap, clean::TypeKind)>; +crate type ExternalPaths = FxHashMap, clean::TypeKind)>; -pub struct DocContext<'tcx> { - pub tcx: TyCtxt<'tcx>, - pub resolver: Rc>, +crate struct DocContext<'tcx> { + crate tcx: TyCtxt<'tcx>, + crate resolver: Rc>, /// Later on moved into `CACHE_KEY` - pub renderinfo: RefCell, + crate renderinfo: RefCell, /// Later on moved through `clean::Crate` into `CACHE_KEY` - pub external_traits: Rc>>, + crate external_traits: Rc>>, /// Used while populating `external_traits` to ensure we don't process the same trait twice at /// the same time. - pub active_extern_traits: RefCell>, + crate active_extern_traits: RefCell>, // The current set of type and lifetime substitutions, // for expanding type aliases at the HIR level: /// Table `DefId` of type parameter -> substituted type - pub ty_substs: RefCell>, + crate ty_substs: RefCell>, /// Table `DefId` of lifetime parameter -> substituted lifetime - pub lt_substs: RefCell>, + crate lt_substs: RefCell>, /// Table `DefId` of const parameter -> substituted const - pub ct_substs: RefCell>, + crate ct_substs: RefCell>, /// Table synthetic type parameter for `impl Trait` in argument position -> bounds - pub impl_trait_bounds: RefCell>>, - pub fake_def_ids: RefCell>, - pub all_fake_def_ids: RefCell>, + crate impl_trait_bounds: RefCell>>, + crate fake_def_ids: RefCell>, + crate all_fake_def_ids: RefCell>, /// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`. // FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set. - pub generated_synthetics: RefCell, DefId)>>, - pub auto_traits: Vec, + crate generated_synthetics: RefCell, DefId)>>, + crate auto_traits: Vec, /// The options given to rustdoc that could be relevant to a pass. - pub render_options: RenderOptions, + crate render_options: RenderOptions, /// The traits in scope for a given module. /// /// See `collect_intra_doc_links::traits_implemented_by` for more details. /// `map>` - pub module_trait_cache: RefCell>>, + crate module_trait_cache: RefCell>>, } impl<'tcx> DocContext<'tcx> { - pub fn sess(&self) -> &Session { + crate fn sess(&self) -> &Session { &self.tcx.sess } - pub fn enter_resolver(&self, f: F) -> R + crate fn enter_resolver(&self, f: F) -> R where F: FnOnce(&mut resolve::Resolver<'_>) -> R, { @@ -90,7 +90,7 @@ impl<'tcx> DocContext<'tcx> { /// Call the closure with the given parameters set as /// the substitutions for a type alias' RHS. - pub fn enter_alias( + crate fn enter_alias( &self, ty_substs: FxHashMap, lt_substs: FxHashMap, @@ -120,7 +120,7 @@ impl<'tcx> DocContext<'tcx> { // Instead, we construct 'fake' def ids, which start immediately after the last DefId. // In the Debug impl for clean::Item, we explicitly check for fake // def ids, as we'll end up with a panic if we use the DefId Debug impl for fake DefIds - pub fn next_def_id(&self, crate_num: CrateNum) -> DefId { + crate fn next_def_id(&self, crate_num: CrateNum) -> DefId { let start_def_id = { let num_def_ids = if crate_num == LOCAL_CRATE { self.tcx.hir().definitions().def_path_table().num_def_ids() @@ -150,7 +150,7 @@ impl<'tcx> DocContext<'tcx> { /// Like `hir().local_def_id_to_hir_id()`, but skips calling it on fake DefIds. /// (This avoids a slice-index-out-of-bounds panic.) - pub fn as_local_hir_id(&self, def_id: DefId) -> Option { + crate fn as_local_hir_id(&self, def_id: DefId) -> Option { if self.all_fake_def_ids.borrow().contains(&def_id) { None } else { @@ -158,7 +158,7 @@ impl<'tcx> DocContext<'tcx> { } } - pub fn stability(&self, id: HirId) -> Option { + crate fn stability(&self, id: HirId) -> Option { self.tcx .hir() .opt_local_def_id(id) @@ -166,7 +166,7 @@ impl<'tcx> DocContext<'tcx> { .cloned() } - pub fn deprecation(&self, id: HirId) -> Option { + crate fn deprecation(&self, id: HirId) -> Option { self.tcx .hir() .opt_local_def_id(id) @@ -178,7 +178,7 @@ impl<'tcx> DocContext<'tcx> { /// /// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one /// will be created for the handler. -pub fn new_handler( +crate fn new_handler( error_format: ErrorOutputType, source_map: Option>, debugging_opts: &DebuggingOptions, @@ -280,7 +280,7 @@ where (lint_opts, lint_caps) } -pub fn run_core( +crate fn run_core( options: RustdocOptions, ) -> (clean::Crate, RenderInfo, RenderOptions, Lrc) { // Parse, resolve, and typecheck the given crate. @@ -725,7 +725,7 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> { /// `DefId` or parameter index (`ty::ParamTy.index`) of a synthetic type parameter /// for `impl Trait` in argument position. #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub enum ImplTraitParam { +crate enum ImplTraitParam { DefId(DefId), ParamIndex(u32), } diff --git a/src/librustdoc/docfs.rs b/src/librustdoc/docfs.rs index 8b52ce710a4..9b740acfcdf 100644 --- a/src/librustdoc/docfs.rs +++ b/src/librustdoc/docfs.rs @@ -24,38 +24,38 @@ macro_rules! try_err { }; } -pub trait PathError { +crate trait PathError { fn new>(e: S, path: P) -> Self where S: ToString + Sized; } -pub struct DocFS { +crate struct DocFS { sync_only: bool, errors: Option>, } impl DocFS { - pub fn new(errors: Sender) -> DocFS { + crate fn new(errors: Sender) -> DocFS { DocFS { sync_only: false, errors: Some(errors) } } - pub fn set_sync_only(&mut self, sync_only: bool) { + crate fn set_sync_only(&mut self, sync_only: bool) { self.sync_only = sync_only; } - pub fn close(&mut self) { + crate fn close(&mut self) { self.errors = None; } - pub fn create_dir_all>(&self, path: P) -> io::Result<()> { + crate fn create_dir_all>(&self, path: P) -> io::Result<()> { // For now, dir creation isn't a huge time consideration, do it // synchronously, which avoids needing ordering between write() actions // and directory creation. fs::create_dir_all(path) } - pub fn write(&self, path: P, contents: C) -> Result<(), E> + crate fn write(&self, path: P, contents: C) -> Result<(), E> where P: AsRef, C: AsRef<[u8]>, diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 5e40e6b151d..c79b2395d23 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -31,17 +31,17 @@ use crate::html::markdown::{self, ErrorCodes, Ignore, LangString}; use crate::passes::span_of_attrs; #[derive(Clone, Default)] -pub struct TestOptions { +crate struct TestOptions { /// Whether to disable the default `extern crate my_crate;` when creating doctests. - pub no_crate_inject: bool, + crate no_crate_inject: bool, /// Whether to emit compilation warnings when compiling doctests. Setting this will suppress /// the default `#![allow(unused)]`. - pub display_warnings: bool, + crate display_warnings: bool, /// Additional crate-level attributes to add to doctests. - pub attrs: Vec, + crate attrs: Vec, } -pub fn run(options: Options) -> Result<(), ErrorReported> { +crate fn run(options: Options) -> Result<(), ErrorReported> { let input = config::Input::File(options.input.clone()); let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; @@ -363,7 +363,7 @@ fn run_test( /// Transforms a test into code that can be compiled into a Rust binary, and returns the number of /// lines before the test code begins. -pub fn make_test( +crate fn make_test( s: &str, cratename: Option<&str>, dont_insert_main: bool, @@ -605,7 +605,7 @@ fn partition_source(s: &str) -> (String, String, String) { (before, after, crates) } -pub trait Tester { +crate trait Tester { fn add_test(&mut self, test: String, config: LangString, line: usize); fn get_line(&self) -> usize { 0 @@ -613,8 +613,8 @@ pub trait Tester { fn register_header(&mut self, _name: &str, _level: u32) {} } -pub struct Collector { - pub tests: Vec, +crate struct Collector { + crate tests: Vec, // The name of the test displayed to the user, separated by `::`. // @@ -650,7 +650,7 @@ pub struct Collector { } impl Collector { - pub fn new( + crate fn new( cratename: String, options: Options, use_headers: bool, @@ -682,7 +682,7 @@ impl Collector { format!("{} - {}(line {})", filename, item_path, line) } - pub fn set_position(&mut self, position: Span) { + crate fn set_position(&mut self, position: Span) { self.position = position; } diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index ee217d99d2c..a80ac1e72fc 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -1,6 +1,6 @@ //! This module is used to store stuff from Rust's AST in a more convenient //! manner (and with prettier names) before cleaning. -pub use self::StructType::*; +crate use self::StructType::*; use rustc_ast as ast; use rustc_span::hygiene::MacroKind; @@ -10,35 +10,35 @@ use rustc_hir as hir; use rustc_hir::def_id::CrateNum; use rustc_hir::HirId; -pub struct Module<'hir> { - pub name: Option, - pub attrs: &'hir [ast::Attribute], - pub where_outer: Span, - pub where_inner: Span, - pub extern_crates: Vec>, - pub imports: Vec>, - pub structs: Vec>, - pub unions: Vec>, - pub enums: Vec>, - pub fns: Vec>, - pub mods: Vec>, - pub id: hir::HirId, - pub typedefs: Vec>, - pub opaque_tys: Vec>, - pub statics: Vec>, - pub constants: Vec>, - pub traits: Vec>, - pub vis: &'hir hir::Visibility<'hir>, - pub impls: Vec>, - pub foreigns: Vec>, - pub macros: Vec>, - pub proc_macros: Vec>, - pub trait_aliases: Vec>, - pub is_crate: bool, +crate struct Module<'hir> { + crate name: Option, + crate attrs: &'hir [ast::Attribute], + crate where_outer: Span, + crate where_inner: Span, + crate extern_crates: Vec>, + crate imports: Vec>, + crate structs: Vec>, + crate unions: Vec>, + crate enums: Vec>, + crate fns: Vec>, + crate mods: Vec>, + crate id: hir::HirId, + crate typedefs: Vec>, + crate opaque_tys: Vec>, + crate statics: Vec>, + crate constants: Vec>, + crate traits: Vec>, + crate vis: &'hir hir::Visibility<'hir>, + crate impls: Vec>, + crate foreigns: Vec>, + crate macros: Vec>, + crate proc_macros: Vec>, + crate trait_aliases: Vec>, + crate is_crate: bool, } impl Module<'hir> { - pub fn new( + crate fn new( name: Option, attrs: &'hir [ast::Attribute], vis: &'hir hir::Visibility<'hir>, @@ -73,7 +73,7 @@ impl Module<'hir> { } #[derive(Debug, Clone, Copy)] -pub enum StructType { +crate enum StructType { /// A braced struct Plain, /// A tuple struct @@ -82,190 +82,190 @@ pub enum StructType { Unit, } -pub struct Struct<'hir> { - pub vis: &'hir hir::Visibility<'hir>, - pub id: hir::HirId, - pub struct_type: StructType, - pub name: Symbol, - pub generics: &'hir hir::Generics<'hir>, - pub attrs: &'hir [ast::Attribute], - pub fields: &'hir [hir::StructField<'hir>], - pub span: Span, +crate struct Struct<'hir> { + crate vis: &'hir hir::Visibility<'hir>, + crate id: hir::HirId, + crate struct_type: StructType, + crate name: Symbol, + crate generics: &'hir hir::Generics<'hir>, + crate attrs: &'hir [ast::Attribute], + crate fields: &'hir [hir::StructField<'hir>], + crate span: Span, } -pub struct Union<'hir> { - pub vis: &'hir hir::Visibility<'hir>, - pub id: hir::HirId, - pub struct_type: StructType, - pub name: Symbol, - pub generics: &'hir hir::Generics<'hir>, - pub attrs: &'hir [ast::Attribute], - pub fields: &'hir [hir::StructField<'hir>], - pub span: Span, +crate struct Union<'hir> { + crate vis: &'hir hir::Visibility<'hir>, + crate id: hir::HirId, + crate struct_type: StructType, + crate name: Symbol, + crate generics: &'hir hir::Generics<'hir>, + crate attrs: &'hir [ast::Attribute], + crate fields: &'hir [hir::StructField<'hir>], + crate span: Span, } -pub struct Enum<'hir> { - pub vis: &'hir hir::Visibility<'hir>, - pub variants: Vec>, - pub generics: &'hir hir::Generics<'hir>, - pub attrs: &'hir [ast::Attribute], - pub id: hir::HirId, - pub span: Span, - pub name: Symbol, +crate struct Enum<'hir> { + crate vis: &'hir hir::Visibility<'hir>, + crate variants: Vec>, + crate generics: &'hir hir::Generics<'hir>, + crate attrs: &'hir [ast::Attribute], + crate id: hir::HirId, + crate span: Span, + crate name: Symbol, } -pub struct Variant<'hir> { - pub name: Symbol, - pub id: hir::HirId, - pub attrs: &'hir [ast::Attribute], - pub def: &'hir hir::VariantData<'hir>, - pub span: Span, +crate struct Variant<'hir> { + crate name: Symbol, + crate id: hir::HirId, + crate attrs: &'hir [ast::Attribute], + crate def: &'hir hir::VariantData<'hir>, + crate span: Span, } -pub struct Function<'hir> { - pub decl: &'hir hir::FnDecl<'hir>, - pub attrs: &'hir [ast::Attribute], - pub id: hir::HirId, - pub name: Symbol, - pub vis: &'hir hir::Visibility<'hir>, - pub header: hir::FnHeader, - pub span: Span, - pub generics: &'hir hir::Generics<'hir>, - pub body: hir::BodyId, +crate struct Function<'hir> { + crate decl: &'hir hir::FnDecl<'hir>, + crate attrs: &'hir [ast::Attribute], + crate id: hir::HirId, + crate name: Symbol, + crate vis: &'hir hir::Visibility<'hir>, + crate header: hir::FnHeader, + crate span: Span, + crate generics: &'hir hir::Generics<'hir>, + crate body: hir::BodyId, } -pub struct Typedef<'hir> { - pub ty: &'hir hir::Ty<'hir>, - pub gen: &'hir hir::Generics<'hir>, - pub name: Symbol, - pub id: hir::HirId, - pub attrs: &'hir [ast::Attribute], - pub span: Span, - pub vis: &'hir hir::Visibility<'hir>, +crate struct Typedef<'hir> { + crate ty: &'hir hir::Ty<'hir>, + crate gen: &'hir hir::Generics<'hir>, + crate name: Symbol, + crate id: hir::HirId, + crate attrs: &'hir [ast::Attribute], + crate span: Span, + crate vis: &'hir hir::Visibility<'hir>, } -pub struct OpaqueTy<'hir> { - pub opaque_ty: &'hir hir::OpaqueTy<'hir>, - pub name: Symbol, - pub id: hir::HirId, - pub attrs: &'hir [ast::Attribute], - pub span: Span, - pub vis: &'hir hir::Visibility<'hir>, +crate struct OpaqueTy<'hir> { + crate opaque_ty: &'hir hir::OpaqueTy<'hir>, + crate name: Symbol, + crate id: hir::HirId, + crate attrs: &'hir [ast::Attribute], + crate span: Span, + crate vis: &'hir hir::Visibility<'hir>, } #[derive(Debug)] -pub struct Static<'hir> { - pub type_: &'hir hir::Ty<'hir>, - pub mutability: hir::Mutability, - pub expr: hir::BodyId, - pub name: Symbol, - pub attrs: &'hir [ast::Attribute], - pub vis: &'hir hir::Visibility<'hir>, - pub id: hir::HirId, - pub span: Span, +crate struct Static<'hir> { + crate type_: &'hir hir::Ty<'hir>, + crate mutability: hir::Mutability, + crate expr: hir::BodyId, + crate name: Symbol, + crate attrs: &'hir [ast::Attribute], + crate vis: &'hir hir::Visibility<'hir>, + crate id: hir::HirId, + crate span: Span, } -pub struct Constant<'hir> { - pub type_: &'hir hir::Ty<'hir>, - pub expr: hir::BodyId, - pub name: Symbol, - pub attrs: &'hir [ast::Attribute], - pub vis: &'hir hir::Visibility<'hir>, - pub id: hir::HirId, - pub span: Span, +crate struct Constant<'hir> { + crate type_: &'hir hir::Ty<'hir>, + crate expr: hir::BodyId, + crate name: Symbol, + crate attrs: &'hir [ast::Attribute], + crate vis: &'hir hir::Visibility<'hir>, + crate id: hir::HirId, + crate span: Span, } -pub struct Trait<'hir> { - pub is_auto: hir::IsAuto, - pub unsafety: hir::Unsafety, - pub name: Symbol, - pub items: Vec<&'hir hir::TraitItem<'hir>>, - pub generics: &'hir hir::Generics<'hir>, - pub bounds: &'hir [hir::GenericBound<'hir>], - pub attrs: &'hir [ast::Attribute], - pub id: hir::HirId, - pub span: Span, - pub vis: &'hir hir::Visibility<'hir>, +crate struct Trait<'hir> { + crate is_auto: hir::IsAuto, + crate unsafety: hir::Unsafety, + crate name: Symbol, + crate items: Vec<&'hir hir::TraitItem<'hir>>, + crate generics: &'hir hir::Generics<'hir>, + crate bounds: &'hir [hir::GenericBound<'hir>], + crate attrs: &'hir [ast::Attribute], + crate id: hir::HirId, + crate span: Span, + crate vis: &'hir hir::Visibility<'hir>, } -pub struct TraitAlias<'hir> { - pub name: Symbol, - pub generics: &'hir hir::Generics<'hir>, - pub bounds: &'hir [hir::GenericBound<'hir>], - pub attrs: &'hir [ast::Attribute], - pub id: hir::HirId, - pub span: Span, - pub vis: &'hir hir::Visibility<'hir>, +crate struct TraitAlias<'hir> { + crate name: Symbol, + crate generics: &'hir hir::Generics<'hir>, + crate bounds: &'hir [hir::GenericBound<'hir>], + crate attrs: &'hir [ast::Attribute], + crate id: hir::HirId, + crate span: Span, + crate vis: &'hir hir::Visibility<'hir>, } #[derive(Debug)] -pub struct Impl<'hir> { - pub unsafety: hir::Unsafety, - pub polarity: hir::ImplPolarity, - pub defaultness: hir::Defaultness, - pub constness: hir::Constness, - pub generics: &'hir hir::Generics<'hir>, - pub trait_: &'hir Option>, - pub for_: &'hir hir::Ty<'hir>, - pub items: Vec<&'hir hir::ImplItem<'hir>>, - pub attrs: &'hir [ast::Attribute], - pub span: Span, - pub vis: &'hir hir::Visibility<'hir>, - pub id: hir::HirId, +crate struct Impl<'hir> { + crate unsafety: hir::Unsafety, + crate polarity: hir::ImplPolarity, + crate defaultness: hir::Defaultness, + crate constness: hir::Constness, + crate generics: &'hir hir::Generics<'hir>, + crate trait_: &'hir Option>, + crate for_: &'hir hir::Ty<'hir>, + crate items: Vec<&'hir hir::ImplItem<'hir>>, + crate attrs: &'hir [ast::Attribute], + crate span: Span, + crate vis: &'hir hir::Visibility<'hir>, + crate id: hir::HirId, } -pub struct ForeignItem<'hir> { - pub vis: &'hir hir::Visibility<'hir>, - pub id: hir::HirId, - pub name: Symbol, - pub kind: &'hir hir::ForeignItemKind<'hir>, - pub attrs: &'hir [ast::Attribute], - pub span: Span, +crate struct ForeignItem<'hir> { + crate vis: &'hir hir::Visibility<'hir>, + crate id: hir::HirId, + crate name: Symbol, + crate kind: &'hir hir::ForeignItemKind<'hir>, + crate attrs: &'hir [ast::Attribute], + crate span: Span, } // For Macro we store the DefId instead of the NodeId, since we also create // these imported macro_rules (which only have a DUMMY_NODE_ID). -pub struct Macro<'hir> { - pub name: Symbol, - pub hid: hir::HirId, - pub def_id: hir::def_id::DefId, - pub attrs: &'hir [ast::Attribute], - pub span: Span, - pub matchers: Vec, - pub imported_from: Option, +crate struct Macro<'hir> { + crate name: Symbol, + crate hid: hir::HirId, + crate def_id: hir::def_id::DefId, + crate attrs: &'hir [ast::Attribute], + crate span: Span, + crate matchers: Vec, + crate imported_from: Option, } -pub struct ExternCrate<'hir> { - pub name: Symbol, - pub hir_id: HirId, - pub cnum: CrateNum, - pub path: Option, - pub vis: &'hir hir::Visibility<'hir>, - pub attrs: &'hir [ast::Attribute], - pub span: Span, +crate struct ExternCrate<'hir> { + crate name: Symbol, + crate hir_id: HirId, + crate cnum: CrateNum, + crate path: Option, + crate vis: &'hir hir::Visibility<'hir>, + crate attrs: &'hir [ast::Attribute], + crate span: Span, } #[derive(Debug)] -pub struct Import<'hir> { - pub name: Symbol, - pub id: hir::HirId, - pub vis: &'hir hir::Visibility<'hir>, - pub attrs: &'hir [ast::Attribute], - pub path: &'hir hir::Path<'hir>, - pub glob: bool, - pub span: Span, +crate struct Import<'hir> { + crate name: Symbol, + crate id: hir::HirId, + crate vis: &'hir hir::Visibility<'hir>, + crate attrs: &'hir [ast::Attribute], + crate path: &'hir hir::Path<'hir>, + crate glob: bool, + crate span: Span, } -pub struct ProcMacro<'hir> { - pub name: Symbol, - pub id: hir::HirId, - pub kind: MacroKind, - pub helpers: Vec, - pub attrs: &'hir [ast::Attribute], - pub span: Span, +crate struct ProcMacro<'hir> { + crate name: Symbol, + crate id: hir::HirId, + crate kind: MacroKind, + crate helpers: Vec, + crate attrs: &'hir [ast::Attribute], + crate span: Span, } -pub fn struct_type_from_def(vdata: &hir::VariantData<'_>) -> StructType { +crate fn struct_type_from_def(vdata: &hir::VariantData<'_>) -> StructType { match *vdata { hir::VariantData::Struct(..) => Plain, hir::VariantData::Tuple(..) => Tuple, diff --git a/src/librustdoc/error.rs b/src/librustdoc/error.rs index 77063ab4639..82d0002b98b 100644 --- a/src/librustdoc/error.rs +++ b/src/librustdoc/error.rs @@ -5,9 +5,9 @@ use std::path::{Path, PathBuf}; use crate::docfs::PathError; #[derive(Debug)] -pub struct Error { - pub file: PathBuf, - pub error: String, +crate struct Error { + crate file: PathBuf, + crate error: String, } impl error::Error for Error {} diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index 900821dbf4a..6c86baa36ac 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -5,20 +5,20 @@ use std::path::Path; use std::str; #[derive(Clone, Debug)] -pub struct ExternalHtml { +crate struct ExternalHtml { /// Content that will be included inline in the section of a /// rendered Markdown file or generated documentation - pub in_header: String, + crate in_header: String, /// Content that will be included inline between and the content of /// a rendered Markdown file or generated documentation - pub before_content: String, + crate before_content: String, /// Content that will be included inline between the content and of /// a rendered Markdown file or generated documentation - pub after_content: String, + crate after_content: String, } impl ExternalHtml { - pub fn load( + crate fn load( in_header: &[String], before_content: &[String], after_content: &[String], @@ -50,12 +50,12 @@ impl ExternalHtml { } } -pub enum LoadStringError { +crate enum LoadStringError { ReadFail, BadUtf8, } -pub fn load_string>( +crate fn load_string>( file_path: P, diag: &rustc_errors::Handler, ) -> Result { diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 694051aa54f..a72860ef0a8 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -1,9 +1,9 @@ use crate::clean::*; -pub struct StripItem(pub Item); +crate struct StripItem(pub Item); impl StripItem { - pub fn strip(self) -> Option { + crate fn strip(self) -> Option { match self.0 { Item { kind: StrippedItem(..), .. } => Some(self.0), mut i => { @@ -14,7 +14,7 @@ impl StripItem { } } -pub trait DocFolder: Sized { +crate trait DocFolder: Sized { fn fold_item(&mut self, item: Item) -> Option { self.fold_item_recur(item) } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 277571b11f5..917c1a95fdb 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -30,25 +30,25 @@ thread_local!(crate static CACHE_KEY: RefCell> = Default::default()); /// to `Send` so it may be stored in a `Arc` instance and shared among the various /// rendering threads. #[derive(Default)] -pub struct Cache { +crate struct Cache { /// Maps a type ID to all known implementations for that type. This is only /// recognized for intra-crate `ResolvedPath` types, and is used to print /// out extra documentation on the page of an enum/struct. /// /// The values of the map are a list of implementations and documentation /// found on that implementation. - pub impls: FxHashMap>, + crate impls: FxHashMap>, /// Maintains a mapping of local crate `DefId`s to the fully qualified name /// and "short type description" of that node. This is used when generating /// URLs when a type is being linked to. External paths are not located in /// this map because the `External` type itself has all the information /// necessary. - pub paths: FxHashMap, ItemType)>, + crate paths: FxHashMap, ItemType)>, /// Similar to `paths`, but only holds external paths. This is only used for /// generating explicit hyperlinks to other crates. - pub external_paths: FxHashMap, ItemType)>, + crate external_paths: FxHashMap, ItemType)>, /// Maps local `DefId`s of exported types to fully qualified paths. /// Unlike 'paths', this mapping ignores any renames that occur @@ -60,36 +60,36 @@ pub struct Cache { /// to the path used if the corresponding type is inlined. By /// doing this, we can detect duplicate impls on a trait page, and only display /// the impl for the inlined type. - pub exact_paths: FxHashMap>, + crate exact_paths: FxHashMap>, /// This map contains information about all known traits of this crate. /// Implementations of a crate should inherit the documentation of the /// parent trait if no extra documentation is specified, and default methods /// should show up in documentation about trait implementations. - pub traits: FxHashMap, + crate traits: FxHashMap, /// When rendering traits, it's often useful to be able to list all /// implementors of the trait, and this mapping is exactly, that: a mapping /// of trait ids to the list of known implementors of the trait - pub implementors: FxHashMap>, + crate implementors: FxHashMap>, /// Cache of where external crate documentation can be found. - pub extern_locations: FxHashMap, + crate extern_locations: FxHashMap, /// Cache of where documentation for primitives can be found. - pub primitive_locations: FxHashMap, + crate primitive_locations: FxHashMap, // Note that external items for which `doc(hidden)` applies to are shown as // non-reachable while local items aren't. This is because we're reusing // the access levels from the privacy check pass. - pub access_levels: AccessLevels, + crate access_levels: AccessLevels, /// The version of the crate being documented, if given from the `--crate-version` flag. - pub crate_version: Option, + crate crate_version: Option, /// Whether to document private items. /// This is stored in `Cache` so it doesn't need to be passed through all rustdoc functions. - pub document_private: bool, + crate document_private: bool, // Private fields only used when initially crawling a crate to build a cache stack: Vec, @@ -98,17 +98,17 @@ pub struct Cache { stripped_mod: bool, masked_crates: FxHashSet, - pub search_index: Vec, - pub deref_trait_did: Option, - pub deref_mut_trait_did: Option, - pub owned_box_did: Option, + crate search_index: Vec, + crate deref_trait_did: Option, + crate deref_mut_trait_did: Option, + crate owned_box_did: Option, // In rare case where a structure is defined in one module but implemented // in another, if the implementing module is parsed before defining module, // then the fully qualified name of the structure isn't presented in `paths` // yet when its implementation methods are being indexed. Caches such methods // and their parent id here and indexes them at the end of crate parsing. - pub orphan_impl_items: Vec<(DefId, clean::Item)>, + crate orphan_impl_items: Vec<(DefId, clean::Item)>, // Similarly to `orphan_impl_items`, sometimes trait impls are picked up // even though the trait itself is not exported. This can happen if a trait @@ -121,11 +121,11 @@ pub struct Cache { /// Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias, /// we need the alias element to have an array of items. - pub aliases: BTreeMap>, + crate aliases: BTreeMap>, } impl Cache { - pub fn from_krate( + crate fn from_krate( render_info: RenderInfo, document_private: bool, extern_html_root_urls: &BTreeMap, diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index a0f4502f750..af512e37460 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -20,7 +20,7 @@ use crate::clean; /// a heading, edit the listing in `html/render.rs`, function `sidebar_module`. This uses an /// ordering based on a helper function inside `item_module`, in the same file. #[derive(Copy, PartialEq, Eq, Clone, Debug, PartialOrd, Ord)] -pub enum ItemType { +crate enum ItemType { Module = 0, ExternCrate = 1, Import = 2, @@ -124,7 +124,7 @@ impl From for ItemType { } impl ItemType { - pub fn as_str(&self) -> &'static str { + crate fn as_str(&self) -> &'static str { match *self { ItemType::Module => "mod", ItemType::ExternCrate => "externcrate", diff --git a/src/librustdoc/formats/mod.rs b/src/librustdoc/formats/mod.rs index b893d6c64ec..55fd4948f45 100644 --- a/src/librustdoc/formats/mod.rs +++ b/src/librustdoc/formats/mod.rs @@ -1,8 +1,8 @@ -pub mod cache; -pub mod item_type; -pub mod renderer; +crate mod cache; +crate mod item_type; +crate mod renderer; -pub use renderer::{run_format, FormatRenderer}; +crate use renderer::{run_format, FormatRenderer}; use rustc_span::def_id::DefId; @@ -11,7 +11,7 @@ use crate::clean::types::GetDefId; /// Specifies whether rendering directly implemented trait items or ones from a certain Deref /// impl. -pub enum AssocItemRender<'a> { +crate enum AssocItemRender<'a> { All, DerefFor { trait_: &'a clean::Type, type_: &'a clean::Type, deref_mut_: bool }, } @@ -19,26 +19,26 @@ pub enum AssocItemRender<'a> { /// For different handling of associated items from the Deref target of a type rather than the type /// itself. #[derive(Copy, Clone, PartialEq)] -pub enum RenderMode { +crate enum RenderMode { Normal, ForDeref { mut_: bool }, } /// Metadata about implementations for a type or trait. #[derive(Clone, Debug)] -pub struct Impl { - pub impl_item: clean::Item, +crate struct Impl { + crate impl_item: clean::Item, } impl Impl { - pub fn inner_impl(&self) -> &clean::Impl { + crate fn inner_impl(&self) -> &clean::Impl { match self.impl_item.kind { clean::ImplItem(ref impl_) => impl_, _ => panic!("non-impl item found in impl"), } } - pub fn trait_did(&self) -> Option { + crate fn trait_did(&self) -> Option { self.inner_impl().trait_.def_id() } } diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 273e2819257..d0fdc69cc19 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -10,7 +10,7 @@ use crate::formats::cache::{Cache, CACHE_KEY}; /// Allows for different backends to rustdoc to be used with the `run_format()` function. Each /// backend renderer has hooks for initialization, documenting an item, entering and exiting a /// module, and cleanup/finalizing output. -pub trait FormatRenderer: Clone { +crate trait FormatRenderer: Clone { /// Sets up any state required for the renderer. When this is called the cache has already been /// populated. fn init( @@ -43,7 +43,7 @@ pub trait FormatRenderer: Clone { } /// Main method for rendering a crate. -pub fn run_format( +crate fn run_format( krate: clean::Crate, options: RenderOptions, render_info: RenderInfo, diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs index 03660c32654..60c19551983 100644 --- a/src/librustdoc/html/escape.rs +++ b/src/librustdoc/html/escape.rs @@ -7,7 +7,7 @@ use std::fmt; /// Wrapper struct which will emit the HTML-escaped version of the contained /// string when passed to a format string. -pub struct Escape<'a>(pub &'a str); +crate struct Escape<'a>(pub &'a str); impl<'a> fmt::Display for Escape<'a> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d18282d6e67..d2722ed1cd2 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -21,7 +21,7 @@ use crate::html::escape::Escape; use crate::html::render::cache::ExternalLocation; use crate::html::render::CURRENT_DEPTH; -pub trait Print { +crate trait Print { fn print(self, buffer: &mut Buffer); } @@ -47,7 +47,7 @@ impl Print for &'_ str { } #[derive(Debug, Clone)] -pub struct Buffer { +crate struct Buffer { for_html: bool, buffer: String, } @@ -115,28 +115,28 @@ impl Buffer { } /// Wrapper struct for properly emitting a function or method declaration. -pub struct Function<'a> { +crate struct Function<'a> { /// The declaration to emit. - pub decl: &'a clean::FnDecl, + crate decl: &'a clean::FnDecl, /// The length of the function header and name. In other words, the number of characters in the /// function declaration up to but not including the parentheses. /// /// Used to determine line-wrapping. - pub header_len: usize, + crate header_len: usize, /// The number of spaces to indent each successive line with, if line-wrapping is necessary. - pub indent: usize, + crate indent: usize, /// Whether the function is async or not. - pub asyncness: hir::IsAsync, + crate asyncness: hir::IsAsync, } /// Wrapper struct for emitting a where-clause from Generics. -pub struct WhereClause<'a> { +crate struct WhereClause<'a> { /// The Generics from which to emit a where-clause. - pub gens: &'a clean::Generics, + crate gens: &'a clean::Generics, /// The number of spaces to indent each line with. - pub indent: usize, + crate indent: usize, /// Whether the where-clause needs to add a comma and newline after the last bound. - pub end_newline: bool, + crate end_newline: bool, } fn comma_sep(items: impl Iterator) -> impl fmt::Display { @@ -480,7 +480,7 @@ impl clean::Path { } } -pub fn href(did: DefId) -> Option<(String, ItemType, Vec)> { +crate fn href(did: DefId) -> Option<(String, ItemType, Vec)> { let cache = cache(); if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private { return None; @@ -618,7 +618,7 @@ fn tybounds(param_names: &Option>) -> impl fmt::Display }) } -pub fn anchor(did: DefId, text: &str) -> impl fmt::Display + '_ { +crate fn anchor(did: DefId, text: &str) -> impl fmt::Display + '_ { display_fn(move |f| { if let Some((url, short_ty, fqp)) = href(did) { write!( @@ -910,7 +910,7 @@ impl clean::Impl { } // The difference from above is that trait is not hyperlinked. -pub fn fmt_impl_for_trait_page(i: &clean::Impl, f: &mut Buffer, use_absolute: bool) { +crate fn fmt_impl_for_trait_page(i: &clean::Impl, f: &mut Buffer, use_absolute: bool) { f.from_display(i.print_inner(false, use_absolute)) } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 4769edc50ff..22233731411 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -15,7 +15,7 @@ use rustc_span::symbol::Ident; use rustc_span::with_default_session_globals; /// Highlights `src`, returning the HTML output. -pub fn render_with_highlighting( +crate fn render_with_highlighting( src: String, class: Option<&str>, playground_button: Option<&str>, diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index db73af7ec16..e8039942f4f 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -7,33 +7,33 @@ use crate::html::format::{Buffer, Print}; use crate::html::render::{ensure_trailing_slash, StylePath}; #[derive(Clone)] -pub struct Layout { - pub logo: String, - pub favicon: String, - pub external_html: ExternalHtml, - pub default_settings: HashMap, - pub krate: String, +crate struct Layout { + crate logo: String, + crate favicon: String, + crate external_html: ExternalHtml, + crate default_settings: HashMap, + crate krate: String, /// The given user css file which allow to customize the generated /// documentation theme. - pub css_file_extension: Option, + crate css_file_extension: Option, /// If false, the `select` element to have search filtering by crates on rendered docs /// won't be generated. - pub generate_search_filter: bool, + crate generate_search_filter: bool, } -pub struct Page<'a> { - pub title: &'a str, - pub css_class: &'a str, - pub root_path: &'a str, - pub static_root_path: Option<&'a str>, - pub description: &'a str, - pub keywords: &'a str, - pub resource_suffix: &'a str, - pub extra_scripts: &'a [&'a str], - pub static_extra_scripts: &'a [&'a str], +crate struct Page<'a> { + crate title: &'a str, + crate css_class: &'a str, + crate root_path: &'a str, + crate static_root_path: Option<&'a str>, + crate description: &'a str, + crate keywords: &'a str, + crate resource_suffix: &'a str, + crate extra_scripts: &'a [&'a str], + crate static_extra_scripts: &'a [&'a str], } -pub fn render( +crate fn render( layout: &Layout, page: &Page<'_>, sidebar: S, @@ -228,7 +228,7 @@ pub fn render( ) } -pub fn redirect(url: &str) -> String { +crate fn redirect(url: &str) -> String { //