From d6c16e425338692d62bc1332c1e72ae2a9cde234 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 14 Nov 2020 17:59:58 -0500 Subject: Make all rustdoc functions and structs crate-private This gives warnings about dead code. --- src/librustdoc/html/escape.rs | 2 +- src/librustdoc/html/format.rs | 28 ++++----- src/librustdoc/html/highlight.rs | 2 +- src/librustdoc/html/layout.rs | 40 ++++++------- src/librustdoc/html/markdown.rs | 112 ++++++++++++++++++------------------ src/librustdoc/html/mod.rs | 4 +- src/librustdoc/html/render/cache.rs | 6 +- src/librustdoc/html/render/mod.rs | 86 +++++++++++++-------------- src/librustdoc/html/sources.rs | 2 +- src/librustdoc/html/static_files.rs | 72 +++++++++++------------ src/librustdoc/html/toc.rs | 12 ++-- 11 files changed, 183 insertions(+), 183 deletions(-) (limited to 'src/librustdoc/html') 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 { //