about summary refs log tree commit diff
path: root/src/librustdoc/html
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
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')
-rw-r--r--src/librustdoc/html/escape.rs2
-rw-r--r--src/librustdoc/html/format.rs28
-rw-r--r--src/librustdoc/html/highlight.rs2
-rw-r--r--src/librustdoc/html/layout.rs40
-rw-r--r--src/librustdoc/html/markdown.rs84
-rw-r--r--src/librustdoc/html/mod.rs2
-rw-r--r--src/librustdoc/html/render/cache.rs6
-rw-r--r--src/librustdoc/html/render/mod.rs86
-rw-r--r--src/librustdoc/html/sources.rs2
-rw-r--r--src/librustdoc/html/static_files.rs72
-rw-r--r--src/librustdoc/html/toc.rs12
11 files changed, 168 insertions, 168 deletions
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<T: fmt::Display>(items: impl Iterator<Item = T>) -> impl fmt::Display {
@@ -480,7 +480,7 @@ impl clean::Path {
     }
 }
 
-pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
+crate fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
     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<Vec<clean::GenericBound>>) -> 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<String, String>,
-    pub krate: String,
+crate struct Layout {
+    crate logo: String,
+    crate favicon: String,
+    crate external_html: ExternalHtml,
+    crate default_settings: HashMap<String, String>,
+    crate krate: String,
     /// The given user css file which allow to customize the generated
     /// documentation theme.
-    pub css_file_extension: Option<PathBuf>,
+    crate css_file_extension: Option<PathBuf>,
     /// 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<T: Print, S: Print>(
+crate fn render<T: Print, S: Print>(
     layout: &Layout,
     page: &Page<'_>,
     sidebar: S,
@@ -228,7 +228,7 @@ pub fn render<T: Print, S: Print>(
     )
 }
 
-pub fn redirect(url: &str) -> String {
+crate fn redirect(url: &str) -> String {
     // <script> triggers a redirect before refresh, so this is fine.
     format!(
         r##"<!DOCTYPE html>
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index ca8b811681c..cdb9aea5ad6 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -62,23 +62,23 @@ pub struct Markdown<'a>(
     pub &'a Option<Playground>,
 );
 /// A tuple struct like `Markdown` that renders the markdown with a table of contents.
-pub struct MarkdownWithToc<'a>(
-    pub &'a str,
-    pub &'a mut IdMap,
-    pub ErrorCodes,
-    pub Edition,
-    pub &'a Option<Playground>,
+crate struct MarkdownWithToc<'a>(
+    crate &'a str,
+    crate &'a mut IdMap,
+    crate ErrorCodes,
+    crate Edition,
+    crate &'a Option<Playground>,
 );
 /// A tuple struct like `Markdown` that renders the markdown escaping HTML tags.
-pub struct MarkdownHtml<'a>(
-    pub &'a str,
-    pub &'a mut IdMap,
-    pub ErrorCodes,
-    pub Edition,
-    pub &'a Option<Playground>,
+crate struct MarkdownHtml<'a>(
+    crate &'a str,
+    crate &'a mut IdMap,
+    crate ErrorCodes,
+    crate Edition,
+    crate &'a Option<Playground>,
 );
 /// A tuple struct like `Markdown` that renders only the first paragraph.
-pub struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
+crate struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
 
 #[derive(Copy, Clone, PartialEq, Debug)]
 pub enum ErrorCodes {
@@ -87,14 +87,14 @@ pub enum ErrorCodes {
 }
 
 impl ErrorCodes {
-    pub fn from(b: bool) -> Self {
+    crate fn from(b: bool) -> Self {
         match b {
             true => ErrorCodes::Yes,
             false => ErrorCodes::No,
         }
     }
 
-    pub fn as_bool(self) -> bool {
+    crate fn as_bool(self) -> bool {
         match self {
             ErrorCodes::Yes => true,
             ErrorCodes::No => false,
@@ -643,7 +643,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for Footnotes<'a, I> {
     }
 }
 
-pub fn find_testable_code<T: doctest::Tester>(
+crate fn find_testable_code<T: doctest::Tester>(
     doc: &str,
     tests: &mut T,
     error_codes: ErrorCodes,
@@ -709,7 +709,7 @@ pub fn find_testable_code<T: doctest::Tester>(
     }
 }
 
-pub struct ExtraInfo<'a, 'b> {
+crate struct ExtraInfo<'a, 'b> {
     hir_id: Option<HirId>,
     item_did: Option<DefId>,
     sp: Span,
@@ -717,11 +717,11 @@ pub struct ExtraInfo<'a, 'b> {
 }
 
 impl<'a, 'b> ExtraInfo<'a, 'b> {
-    pub fn new(tcx: &'a TyCtxt<'b>, hir_id: HirId, sp: Span) -> ExtraInfo<'a, 'b> {
+    crate fn new(tcx: &'a TyCtxt<'b>, hir_id: HirId, sp: Span) -> ExtraInfo<'a, 'b> {
         ExtraInfo { hir_id: Some(hir_id), item_did: None, sp, tcx }
     }
 
-    pub fn new_did(tcx: &'a TyCtxt<'b>, did: DefId, sp: Span) -> ExtraInfo<'a, 'b> {
+    crate fn new_did(tcx: &'a TyCtxt<'b>, did: DefId, sp: Span) -> ExtraInfo<'a, 'b> {
         ExtraInfo { hir_id: None, item_did: Some(did), sp, tcx }
     }
 
@@ -753,21 +753,21 @@ impl<'a, 'b> ExtraInfo<'a, 'b> {
 }
 
 #[derive(Eq, PartialEq, Clone, Debug)]
-pub struct LangString {
+crate struct LangString {
     original: String,
-    pub should_panic: bool,
-    pub no_run: bool,
-    pub ignore: Ignore,
-    pub rust: bool,
-    pub test_harness: bool,
-    pub compile_fail: bool,
-    pub error_codes: Vec<String>,
-    pub allow_fail: bool,
-    pub edition: Option<Edition>,
+    crate should_panic: bool,
+    crate no_run: bool,
+    crate ignore: Ignore,
+    crate rust: bool,
+    crate test_harness: bool,
+    crate compile_fail: bool,
+    crate error_codes: Vec<String>,
+    crate allow_fail: bool,
+    crate edition: Option<Edition>,
 }
 
 #[derive(Eq, PartialEq, Clone, Debug)]
-pub enum Ignore {
+crate enum Ignore {
     All,
     None,
     Some(Vec<String>),
@@ -955,7 +955,7 @@ impl Markdown<'_> {
 }
 
 impl MarkdownWithToc<'_> {
-    pub fn into_string(self) -> String {
+    crate fn into_string(self) -> String {
         let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;
 
         let p = Parser::new_ext(md, opts());
@@ -976,7 +976,7 @@ impl MarkdownWithToc<'_> {
 }
 
 impl MarkdownHtml<'_> {
-    pub fn into_string(self) -> String {
+    crate fn into_string(self) -> String {
         let MarkdownHtml(md, mut ids, codes, edition, playground) = self;
 
         // This is actually common enough to special-case
@@ -1003,7 +1003,7 @@ impl MarkdownHtml<'_> {
 }
 
 impl MarkdownSummaryLine<'_> {
-    pub fn into_string(self) -> String {
+    crate fn into_string(self) -> String {
         let MarkdownSummaryLine(md, links) = self;
         // This is actually common enough to special-case
         if md.is_empty() {
@@ -1039,7 +1039,7 @@ impl MarkdownSummaryLine<'_> {
 /// - Headings, links, and formatting are stripped.
 /// - Inline code is rendered as-is, surrounded by backticks.
 /// - HTML and code blocks are ignored.
-pub fn plain_text_summary(md: &str) -> String {
+crate fn plain_text_summary(md: &str) -> String {
     if md.is_empty() {
         return String::new();
     }
@@ -1064,7 +1064,7 @@ pub fn plain_text_summary(md: &str) -> String {
     s
 }
 
-pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
+crate fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
     if md.is_empty() {
         return vec![];
     }
@@ -1120,11 +1120,11 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
 crate struct RustCodeBlock {
     /// The range in the markdown that the code block occupies. Note that this includes the fences
     /// for fenced code blocks.
-    pub range: Range<usize>,
+    crate range: Range<usize>,
     /// The range in the markdown that the code within the code block occupies.
-    pub code: Range<usize>,
-    pub is_fenced: bool,
-    pub syntax: Option<String>,
+    crate code: Range<usize>,
+    crate is_fenced: bool,
+    crate syntax: Option<String>,
 }
 
 /// Returns a range of bytes for each code block in the markdown that is tagged as `rust` or
@@ -1247,17 +1247,17 @@ impl IdMap {
         IdMap { map: init_id_map() }
     }
 
-    pub fn populate<I: IntoIterator<Item = String>>(&mut self, ids: I) {
+    crate fn populate<I: IntoIterator<Item = String>>(&mut self, ids: I) {
         for id in ids {
             let _ = self.derive(id);
         }
     }
 
-    pub fn reset(&mut self) {
+    crate fn reset(&mut self) {
         self.map = init_id_map();
     }
 
-    pub fn derive(&mut self, candidate: String) -> String {
+    crate fn derive(&mut self, candidate: String) -> String {
         let id = match self.map.get_mut(&candidate) {
             None => candidate,
             Some(a) => {
diff --git a/src/librustdoc/html/mod.rs b/src/librustdoc/html/mod.rs
index 367538d440e..403a9303c3f 100644
--- a/src/librustdoc/html/mod.rs
+++ b/src/librustdoc/html/mod.rs
@@ -3,7 +3,7 @@ crate mod format;
 crate mod highlight;
 crate mod layout;
 pub mod markdown;
-pub mod render;
+crate mod render;
 crate mod sources;
 crate mod static_files;
 crate mod toc;
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.
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs
index b487b399521..0f82649409f 100644
--- a/src/librustdoc/html/sources.rs
+++ b/src/librustdoc/html/sources.rs
@@ -137,7 +137,7 @@ impl<'a> SourceCollector<'a> {
 /// static HTML tree. Each component in the cleaned path will be passed as an
 /// argument to `f`. The very last component of the path (ie the file name) will
 /// be passed to `f` if `keep_filename` is true, and ignored otherwise.
-pub fn clean_path<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F)
+crate fn clean_path<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F)
 where
     F: FnMut(&OsStr),
 {
diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs
index 213c7f3aab8..132ac42c422 100644
--- a/src/librustdoc/html/static_files.rs
+++ b/src/librustdoc/html/static_files.rs
@@ -8,111 +8,111 @@
 //! directly written to a `Write` handle.
 
 /// The file contents of the main `rustdoc.css` file, responsible for the core layout of the page.
-pub static RUSTDOC_CSS: &str = include_str!("static/rustdoc.css");
+crate static RUSTDOC_CSS: &str = include_str!("static/rustdoc.css");
 
 /// The file contents of `settings.css`, responsible for the items on the settings page.
-pub static SETTINGS_CSS: &str = include_str!("static/settings.css");
+crate static SETTINGS_CSS: &str = include_str!("static/settings.css");
 
 /// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled.
-pub static NOSCRIPT_CSS: &str = include_str!("static/noscript.css");
+crate static NOSCRIPT_CSS: &str = include_str!("static/noscript.css");
 
 /// The file contents of `normalize.css`, included to even out standard elements between browser
 /// implementations.
-pub static NORMALIZE_CSS: &str = include_str!("static/normalize.css");
+crate static NORMALIZE_CSS: &str = include_str!("static/normalize.css");
 
 /// The file contents of `main.js`, which contains the core JavaScript used on documentation pages,
 /// including search behavior and docblock folding, among others.
-pub static MAIN_JS: &str = include_str!("static/main.js");
+crate static MAIN_JS: &str = include_str!("static/main.js");
 
 /// The file contents of `settings.js`, which contains the JavaScript used to handle the settings
 /// page.
-pub static SETTINGS_JS: &str = include_str!("static/settings.js");
+crate static SETTINGS_JS: &str = include_str!("static/settings.js");
 
 /// The file contents of `storage.js`, which contains functionality related to browser Local
 /// Storage, used to store documentation settings.
-pub static STORAGE_JS: &str = include_str!("static/storage.js");
+crate static STORAGE_JS: &str = include_str!("static/storage.js");
 
 /// The file contents of `brush.svg`, the icon used for the theme-switch button.
-pub static BRUSH_SVG: &[u8] = include_bytes!("static/brush.svg");
+crate static BRUSH_SVG: &[u8] = include_bytes!("static/brush.svg");
 
 /// The file contents of `wheel.svg`, the icon used for the settings button.
-pub static WHEEL_SVG: &[u8] = include_bytes!("static/wheel.svg");
+crate static WHEEL_SVG: &[u8] = include_bytes!("static/wheel.svg");
 
 /// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox.
-pub static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/down-arrow.svg");
+crate static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/down-arrow.svg");
 
 /// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation
 /// output.
-pub static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt");
+crate static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt");
 
 /// The contents of `LICENSE-APACHE.txt`, the text of the Apache License, version 2.0.
-pub static LICENSE_APACHE: &[u8] = include_bytes!("static/LICENSE-APACHE.txt");
+crate static LICENSE_APACHE: &[u8] = include_bytes!("static/LICENSE-APACHE.txt");
 
 /// The contents of `LICENSE-MIT.txt`, the text of the MIT License.
-pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
+crate static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
 
 /// The contents of `rust-logo.png`, the default icon of the documentation.
-pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
+crate static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
 /// The default documentation favicons (SVG and PNG fallbacks)
-pub static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/favicon.svg");
-pub static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/favicon-16x16.png");
-pub static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/favicon-32x32.png");
+crate static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/favicon.svg");
+crate static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/favicon-16x16.png");
+crate static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/favicon-32x32.png");
 
 /// The built-in themes given to every documentation site.
-pub mod themes {
+crate mod themes {
     /// The "light" theme, selected by default when no setting is available. Used as the basis for
     /// the `--check-theme` functionality.
-    pub static LIGHT: &str = include_str!("static/themes/light.css");
+    crate static LIGHT: &str = include_str!("static/themes/light.css");
 
     /// The "dark" theme.
-    pub static DARK: &str = include_str!("static/themes/dark.css");
+    crate static DARK: &str = include_str!("static/themes/dark.css");
 
     /// The "ayu" theme.
-    pub static AYU: &str = include_str!("static/themes/ayu.css");
+    crate static AYU: &str = include_str!("static/themes/ayu.css");
 }
 
 /// Files related to the Fira Sans font.
-pub mod fira_sans {
+crate mod fira_sans {
     /// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font.
-    pub static REGULAR: &[u8] = include_bytes!("static/FiraSans-Regular.woff");
+    crate static REGULAR: &[u8] = include_bytes!("static/FiraSans-Regular.woff");
 
     /// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font.
-    pub static MEDIUM: &[u8] = include_bytes!("static/FiraSans-Medium.woff");
+    crate static MEDIUM: &[u8] = include_bytes!("static/FiraSans-Medium.woff");
 
     /// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font.
-    pub static LICENSE: &[u8] = include_bytes!("static/FiraSans-LICENSE.txt");
+    crate static LICENSE: &[u8] = include_bytes!("static/FiraSans-LICENSE.txt");
 }
 
 /// Files related to the Source Serif Pro font.
-pub mod source_serif_pro {
+crate mod source_serif_pro {
     /// The file `SourceSerifPro-Regular.ttf.woff`, the Regular variant of the Source Serif Pro
     /// font.
-    pub static REGULAR: &[u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff");
+    crate static REGULAR: &[u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff");
 
     /// The file `SourceSerifPro-Bold.ttf.woff`, the Bold variant of the Source Serif Pro font.
-    pub static BOLD: &[u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff");
+    crate static BOLD: &[u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff");
 
     /// The file `SourceSerifPro-It.ttf.woff`, the Italic variant of the Source Serif Pro font.
-    pub static ITALIC: &[u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff");
+    crate static ITALIC: &[u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff");
 
     /// The file `SourceSerifPro-LICENSE.txt`, the license text for the Source Serif Pro font.
-    pub static LICENSE: &[u8] = include_bytes!("static/SourceSerifPro-LICENSE.md");
+    crate static LICENSE: &[u8] = include_bytes!("static/SourceSerifPro-LICENSE.md");
 }
 
 /// Files related to the Source Code Pro font.
-pub mod source_code_pro {
+crate mod source_code_pro {
     /// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font.
-    pub static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.woff");
+    crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.woff");
 
     /// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font.
-    pub static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.woff");
+    crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.woff");
 
     /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
-    pub static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");
+    crate static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");
 }
 
 /// Files related to the sidebar in rustdoc sources.
-pub mod sidebar {
+crate mod sidebar {
     /// File script to handle sidebar.
-    pub static SOURCE_SCRIPT: &str = include_str!("static/source-script.js");
+    crate static SOURCE_SCRIPT: &str = include_str!("static/source-script.js");
 }
diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs
index 721988e29a6..b39a4e179cd 100644
--- a/src/librustdoc/html/toc.rs
+++ b/src/librustdoc/html/toc.rs
@@ -2,7 +2,7 @@
 
 /// A (recursive) table of contents
 #[derive(Debug, PartialEq)]
-pub struct Toc {
+crate struct Toc {
     /// The levels are strictly decreasing, i.e.
     ///
     /// `entries[0].level >= entries[1].level >= ...`
@@ -26,7 +26,7 @@ impl Toc {
 }
 
 #[derive(Debug, PartialEq)]
-pub struct TocEntry {
+crate struct TocEntry {
     level: u32,
     sec_number: String,
     name: String,
@@ -36,7 +36,7 @@ pub struct TocEntry {
 
 /// Progressive construction of a table of contents.
 #[derive(PartialEq)]
-pub struct TocBuilder {
+crate struct TocBuilder {
     top_level: Toc,
     /// The current hierarchy of parent headings, the levels are
     /// strictly increasing (i.e., `chain[0].level < chain[1].level <
@@ -50,12 +50,12 @@ pub struct TocBuilder {
 }
 
 impl TocBuilder {
-    pub fn new() -> TocBuilder {
+    crate fn new() -> TocBuilder {
         TocBuilder { top_level: Toc { entries: Vec::new() }, chain: Vec::new() }
     }
 
     /// Converts into a true `Toc` struct.
-    pub fn into_toc(mut self) -> Toc {
+    crate fn into_toc(mut self) -> Toc {
         // we know all levels are >= 1.
         self.fold_until(0);
         self.top_level
@@ -115,7 +115,7 @@ impl TocBuilder {
     /// Push a level `level` heading into the appropriate place in the
     /// hierarchy, returning a string containing the section number in
     /// `<num>.<num>.<num>` format.
-    pub fn push(&mut self, level: u32, name: String, id: String) -> &str {
+    crate fn push(&mut self, level: u32, name: String, id: String) -> &str {
         assert!(level >= 1);
 
         // collapse all previous sections into their parents until we