about summary refs log tree commit diff
path: root/src/librustdoc/html/render
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-11-16 17:26:36 +0100
committerGitHub <noreply@github.com>2020-11-16 17:26:36 +0100
commitc3da682249d2d6fc80735e8b0da8be4b2451f551 (patch)
treea6a5925477829a250c16f155764c9247ba62e302 /src/librustdoc/html/render
parent835faa532f485883a3da86c14cfe4abdbaa3ce71 (diff)
parent9b84c914341ffba075fbebc846eafce6e2b58ca0 (diff)
downloadrust-c3da682249d2d6fc80735e8b0da8be4b2451f551.tar.gz
rust-c3da682249d2d6fc80735e8b0da8be4b2451f551.zip
Rollup merge of #79061 - jyn514:no-pub, r=GuillaumeGomez
Make all rustdoc functions and structs crate-private

This gives warnings when code is no longer used, which will be helpful when https://github.com/rust-lang/rust/pull/77820 and https://github.com/rust-lang/rust/pull/78082 land.

AFAIK no one is using this API.

r? ``@GuillaumeGomez``
cc ``@rust-lang/rustdoc``
Diffstat (limited to 'src/librustdoc/html/render')
-rw-r--r--src/librustdoc/html/render/cache.rs6
-rw-r--r--src/librustdoc/html/render/mod.rs86
2 files changed, 46 insertions, 46 deletions
diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs
index 0541bf118e1..cef9b8952dd 100644
--- a/src/librustdoc/html/render/cache.rs
+++ b/src/librustdoc/html/render/cache.rs
@@ -13,7 +13,7 @@ use crate::html::render::{plain_text_summary, shorten};
 use crate::html::render::{Generic, IndexItem, IndexItemFunctionType, RenderType, TypeWithKind};
 
 /// Indicates where an external crate can be found.
-pub enum ExternalLocation {
+crate enum ExternalLocation {
     /// Remote URL root of the external crate
     Remote(String),
     /// This external crate can be found in the local doc/ folder
@@ -24,7 +24,7 @@ pub enum ExternalLocation {
 
 /// Attempts to find where an external crate is located, given that we're
 /// rendering in to the specified source destination.
-pub fn extern_location(
+crate fn extern_location(
     e: &clean::ExternalCrate,
     extern_url: Option<&str>,
     dst: &Path,
@@ -62,7 +62,7 @@ pub fn extern_location(
 }
 
 /// Builds the search index from the collected metadata
-pub fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
+crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
     let mut defid_to_pathid = FxHashMap::default();
     let mut crate_items = Vec::with_capacity(cache.search_index.len());
     let mut crate_paths = vec![];
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index fc0ce4b1f09..78822e678d4 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -25,7 +25,7 @@
 //! These threads are not parallelized (they haven't been a bottleneck yet), and
 //! both occur before the crate is rendered.
 
-pub mod cache;
+crate mod cache;
 
 #[cfg(test)]
 mod tests;
@@ -82,7 +82,7 @@ use crate::html::{highlight, layout, static_files};
 use cache::{build_index, ExternalLocation};
 
 /// A pair of name and its optional document.
-pub type NameDoc = (String, Option<String>);
+crate type NameDoc = (String, Option<String>);
 
 crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
     crate::html::format::display_fn(move |f| {
@@ -101,60 +101,60 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
 crate struct Context {
     /// Current hierarchy of components leading down to what's currently being
     /// rendered
-    pub current: Vec<String>,
+    crate current: Vec<String>,
     /// The current destination folder of where HTML artifacts should be placed.
     /// This changes as the context descends into the module hierarchy.
-    pub dst: PathBuf,
+    crate dst: PathBuf,
     /// A flag, which when `true`, will render pages which redirect to the
     /// real location of an item. This is used to allow external links to
     /// publicly reused items to redirect to the right location.
-    pub render_redirect_pages: bool,
+    crate render_redirect_pages: bool,
     /// The map used to ensure all generated 'id=' attributes are unique.
     id_map: Rc<RefCell<IdMap>>,
-    pub shared: Arc<SharedContext>,
+    crate shared: Arc<SharedContext>,
     all: Rc<RefCell<AllTypes>>,
     /// Storage for the errors produced while generating documentation so they
     /// can be printed together at the end.
-    pub errors: Rc<Receiver<String>>,
+    crate errors: Rc<Receiver<String>>,
 }
 
 crate struct SharedContext {
     /// The path to the crate root source minus the file name.
     /// Used for simplifying paths to the highlighted source code files.
-    pub src_root: PathBuf,
+    crate src_root: PathBuf,
     /// This describes the layout of each page, and is not modified after
     /// creation of the context (contains info like the favicon and added html).
-    pub layout: layout::Layout,
+    crate layout: layout::Layout,
     /// This flag indicates whether `[src]` links should be generated or not. If
     /// the source files are present in the html rendering, then this will be
     /// `true`.
-    pub include_sources: bool,
+    crate include_sources: bool,
     /// The local file sources we've emitted and their respective url-paths.
-    pub local_sources: FxHashMap<PathBuf, String>,
+    crate local_sources: FxHashMap<PathBuf, String>,
     /// Whether the collapsed pass ran
-    pub collapsed: bool,
+    crate collapsed: bool,
     /// The base-URL of the issue tracker for when an item has been tagged with
     /// an issue number.
-    pub issue_tracker_base_url: Option<String>,
+    crate issue_tracker_base_url: Option<String>,
     /// The directories that have already been created in this doc run. Used to reduce the number
     /// of spurious `create_dir_all` calls.
-    pub created_dirs: RefCell<FxHashSet<PathBuf>>,
+    crate created_dirs: RefCell<FxHashSet<PathBuf>>,
     /// This flag indicates whether listings of modules (in the side bar and documentation itself)
     /// should be ordered alphabetically or in order of appearance (in the source code).
-    pub sort_modules_alphabetically: bool,
+    crate sort_modules_alphabetically: bool,
     /// Additional CSS files to be added to the generated docs.
-    pub style_files: Vec<StylePath>,
+    crate style_files: Vec<StylePath>,
     /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes
     /// "light-v2.css").
-    pub resource_suffix: String,
+    crate resource_suffix: String,
     /// Optional path string to be used to load static files on output pages. If not set, uses
     /// combinations of `../` to reach the documentation root.
-    pub static_root_path: Option<String>,
+    crate static_root_path: Option<String>,
     /// The fs handle we are working with.
-    pub fs: DocFS,
+    crate fs: DocFS,
     /// The default edition used to parse doctests.
-    pub edition: Edition,
-    pub codes: ErrorCodes,
+    crate edition: Edition,
+    crate codes: ErrorCodes,
     playground: Option<markdown::Playground>,
 }
 
@@ -186,7 +186,7 @@ impl SharedContext {
 
     /// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the
     /// `collapsed_doc_value` of the given item.
-    pub fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<Cow<'a, str>> {
+    crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<Cow<'a, str>> {
         if self.collapsed {
             item.collapsed_doc_value().map(|s| s.into())
         } else {
@@ -201,14 +201,14 @@ impl SharedContext {
 /// Struct representing one entry in the JS search index. These are all emitted
 /// by hand to a large JS file at the end of cache-creation.
 #[derive(Debug)]
-pub struct IndexItem {
-    pub ty: ItemType,
-    pub name: String,
-    pub path: String,
-    pub desc: String,
-    pub parent: Option<DefId>,
-    pub parent_idx: Option<usize>,
-    pub search_type: Option<IndexItemFunctionType>,
+crate struct IndexItem {
+    crate ty: ItemType,
+    crate name: String,
+    crate path: String,
+    crate desc: String,
+    crate parent: Option<DefId>,
+    crate parent_idx: Option<usize>,
+    crate search_type: Option<IndexItemFunctionType>,
 }
 
 impl Serialize for IndexItem {
@@ -282,7 +282,7 @@ impl Serialize for Generic {
 
 /// Full type of functions/methods in the search index.
 #[derive(Debug)]
-pub struct IndexItemFunctionType {
+crate struct IndexItemFunctionType {
     inputs: Vec<TypeWithKind>,
     output: Option<Vec<TypeWithKind>>,
 }
@@ -340,16 +340,16 @@ impl Serialize for TypeWithKind {
 }
 
 #[derive(Debug, Clone)]
-pub struct StylePath {
+crate struct StylePath {
     /// The path to the theme
-    pub path: PathBuf,
+    crate path: PathBuf,
     /// What the `disabled` attribute should be set to in the HTML tag
-    pub disabled: bool,
+    crate disabled: bool,
 }
 
-thread_local!(pub static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
+thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
 
-pub fn initial_ids() -> Vec<String> {
+crate fn initial_ids() -> Vec<String> {
     [
         "main",
         "search",
@@ -1701,7 +1701,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
 
     // Write `src` tag
     //
-    // When this item is part of a `pub use` in a downstream crate, the
+    // When this item is part of a `crate use` in a downstream crate, the
     // [src] link in the downstream documentation will actually come back to
     // this page, and this link will be auto-clicked. The `id` attribute is
     // used to find the link to auto-click.
@@ -1994,7 +1994,7 @@ fn document_non_exhaustive(w: &mut Buffer, item: &clean::Item) {
 }
 
 /// Compare two strings treating multi-digit numbers as single units (i.e. natural sort order).
-pub fn compare_names(mut lhs: &str, mut rhs: &str) -> Ordering {
+crate fn compare_names(mut lhs: &str, mut rhs: &str) -> Ordering {
     /// Takes a non-numeric and a numeric part from the given &str.
     fn take_parts<'a>(s: &mut &'a str) -> (&'a str, &'a str) {
         let i = s.find(|c: char| c.is_ascii_digit());
@@ -2081,14 +2081,14 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
     // This call is to remove re-export duplicates in cases such as:
     //
     // ```
-    // pub mod foo {
-    //     pub mod bar {
-    //         pub trait Double { fn foo(); }
+    // crate mod foo {
+    //     crate mod bar {
+    //         crate trait Double { fn foo(); }
     //     }
     // }
     //
-    // pub use foo::bar::*;
-    // pub use foo::*;
+    // crate use foo::bar::*;
+    // crate use foo::*;
     // ```
     //
     // `Double` will appear twice in the generated docs.