mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Remove crate
visibility modifier in libs, tests
This commit is contained in:
parent
49c82f31a8
commit
6970246886
@ -20,12 +20,12 @@ struct RegionDeps<'tcx> {
|
||||
smaller: FxHashSet<RegionTarget<'tcx>>,
|
||||
}
|
||||
|
||||
crate struct AutoTraitFinder<'a, 'tcx> {
|
||||
crate cx: &'a mut core::DocContext<'tcx>,
|
||||
pub(crate) struct AutoTraitFinder<'a, 'tcx> {
|
||||
pub(crate) cx: &'a mut core::DocContext<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
crate fn new(cx: &'a mut core::DocContext<'tcx>) -> Self {
|
||||
pub(crate) fn new(cx: &'a mut core::DocContext<'tcx>) -> Self {
|
||||
AutoTraitFinder { cx }
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
crate fn get_auto_trait_impls(&mut self, item_def_id: DefId) -> Vec<Item> {
|
||||
pub(crate) fn get_auto_trait_impls(&mut self, item_def_id: DefId) -> Vec<Item> {
|
||||
let tcx = self.cx.tcx;
|
||||
let param_env = tcx.param_env(item_def_id);
|
||||
let ty = tcx.type_of(item_def_id);
|
||||
|
@ -8,12 +8,12 @@ use rustc_span::DUMMY_SP;
|
||||
|
||||
use super::*;
|
||||
|
||||
crate struct BlanketImplFinder<'a, 'tcx> {
|
||||
crate cx: &'a mut core::DocContext<'tcx>,
|
||||
pub(crate) struct BlanketImplFinder<'a, 'tcx> {
|
||||
pub(crate) cx: &'a mut core::DocContext<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
crate fn get_blanket_impls(&mut self, item_def_id: DefId) -> Vec<Item> {
|
||||
pub(crate) fn get_blanket_impls(&mut self, item_def_id: DefId) -> Vec<Item> {
|
||||
let param_env = self.cx.tcx.param_env(item_def_id);
|
||||
let ty = self.cx.tcx.bound_type_of(item_def_id);
|
||||
|
||||
|
@ -21,7 +21,7 @@ use crate::html::escape::Escape;
|
||||
mod tests;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
crate enum Cfg {
|
||||
pub(crate) enum Cfg {
|
||||
/// Accepts all configurations.
|
||||
True,
|
||||
/// Denies all configurations.
|
||||
@ -37,9 +37,9 @@ crate enum Cfg {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
crate struct InvalidCfgError {
|
||||
crate msg: &'static str,
|
||||
crate span: Span,
|
||||
pub(crate) struct InvalidCfgError {
|
||||
pub(crate) msg: &'static str,
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
impl Cfg {
|
||||
@ -56,7 +56,7 @@ impl Cfg {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn parse_without(
|
||||
pub(crate) fn parse_without(
|
||||
cfg: &MetaItem,
|
||||
exclude: &FxHashSet<Cfg>,
|
||||
) -> Result<Option<Cfg>, InvalidCfgError> {
|
||||
@ -117,7 +117,7 @@ impl Cfg {
|
||||
///
|
||||
/// If the content is not properly formatted, it will return an error indicating what and where
|
||||
/// the error is.
|
||||
crate fn parse(cfg: &MetaItem) -> Result<Cfg, InvalidCfgError> {
|
||||
pub(crate) fn parse(cfg: &MetaItem) -> Result<Cfg, InvalidCfgError> {
|
||||
Self::parse_without(cfg, &FxHashSet::default()).map(|ret| ret.unwrap())
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ impl Cfg {
|
||||
///
|
||||
/// Equivalent to `attr::cfg_matches`.
|
||||
// FIXME: Actually make use of `features`.
|
||||
crate fn matches(&self, parse_sess: &ParseSess, features: Option<&Features>) -> bool {
|
||||
pub(crate) fn matches(&self, parse_sess: &ParseSess, features: Option<&Features>) -> bool {
|
||||
match *self {
|
||||
Cfg::False => false,
|
||||
Cfg::True => true,
|
||||
|
@ -38,7 +38,7 @@ type Attrs<'hir> = &'hir [ast::Attribute];
|
||||
/// and `Some` of a vector of items if it was successfully expanded.
|
||||
///
|
||||
/// `parent_module` refers to the parent of the *re-export*, not the original item.
|
||||
crate fn try_inline(
|
||||
pub(crate) fn try_inline(
|
||||
cx: &mut DocContext<'_>,
|
||||
parent_module: DefId,
|
||||
import_def_id: Option<DefId>,
|
||||
@ -134,7 +134,7 @@ crate fn try_inline(
|
||||
Some(ret)
|
||||
}
|
||||
|
||||
crate fn try_inline_glob(
|
||||
pub(crate) fn try_inline_glob(
|
||||
cx: &mut DocContext<'_>,
|
||||
res: Res,
|
||||
visited: &mut FxHashSet<DefId>,
|
||||
@ -154,7 +154,7 @@ crate fn try_inline_glob(
|
||||
}
|
||||
}
|
||||
|
||||
crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
|
||||
pub(crate) fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
|
||||
cx.tcx.get_attrs_unchecked(did)
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
|
||||
///
|
||||
/// These names are used later on by HTML rendering to generate things like
|
||||
/// source links back to the original item.
|
||||
crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType) {
|
||||
pub(crate) fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType) {
|
||||
let crate_name = cx.tcx.crate_name(did.krate);
|
||||
|
||||
let relative =
|
||||
@ -190,7 +190,7 @@ crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType)
|
||||
}
|
||||
}
|
||||
|
||||
crate fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean::Trait {
|
||||
pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean::Trait {
|
||||
let trait_items = cx
|
||||
.tcx
|
||||
.associated_items(did)
|
||||
@ -274,7 +274,7 @@ fn build_type_alias(cx: &mut DocContext<'_>, did: DefId) -> clean::Typedef {
|
||||
}
|
||||
|
||||
/// Builds all inherent implementations of an ADT (struct/union/enum) or Trait item/path/reexport.
|
||||
crate fn build_impls(
|
||||
pub(crate) fn build_impls(
|
||||
cx: &mut DocContext<'_>,
|
||||
parent_module: Option<DefId>,
|
||||
did: DefId,
|
||||
@ -318,7 +318,7 @@ fn merge_attrs(
|
||||
}
|
||||
|
||||
/// Inline an `impl`, inherent or of a trait. The `did` must be for an `impl`.
|
||||
crate fn build_impl(
|
||||
pub(crate) fn build_impl(
|
||||
cx: &mut DocContext<'_>,
|
||||
parent_module: Option<DefId>,
|
||||
did: DefId,
|
||||
@ -565,7 +565,7 @@ fn build_module(
|
||||
clean::Module { items, span }
|
||||
}
|
||||
|
||||
crate fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
|
||||
pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
|
||||
if let Some(did) = did.as_local() {
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(did);
|
||||
rustc_hir_pretty::id_to_string(&tcx.hir(), hir_id)
|
||||
@ -670,7 +670,7 @@ fn separate_supertrait_bounds(
|
||||
(g, ty_bounds)
|
||||
}
|
||||
|
||||
crate fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
|
||||
pub(crate) fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
|
||||
if did.is_local() {
|
||||
return;
|
||||
}
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
mod auto_trait;
|
||||
mod blanket_impl;
|
||||
crate mod cfg;
|
||||
crate mod inline;
|
||||
pub(crate) mod cfg;
|
||||
pub(crate) mod inline;
|
||||
mod render_macro_matchers;
|
||||
mod simplify;
|
||||
crate mod types;
|
||||
crate mod utils;
|
||||
pub(crate) mod types;
|
||||
pub(crate) mod utils;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr as attr;
|
||||
@ -41,10 +41,10 @@ use crate::visit_ast::Module as DocModule;
|
||||
|
||||
use utils::*;
|
||||
|
||||
crate use self::types::*;
|
||||
crate use self::utils::{get_auto_trait_and_blanket_impls, krate, register_res};
|
||||
pub(crate) use self::types::*;
|
||||
pub(crate) use self::utils::{get_auto_trait_and_blanket_impls, krate, register_res};
|
||||
|
||||
crate trait Clean<T> {
|
||||
pub(crate) trait Clean<T> {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> T;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ use crate::clean::GenericArgs as PP;
|
||||
use crate::clean::WherePredicate as WP;
|
||||
use crate::core::DocContext;
|
||||
|
||||
crate fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
||||
pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
||||
// First, partition the where clause into its separate components.
|
||||
//
|
||||
// We use `FxIndexMap` so that the insertion order is preserved to prevent messing up to
|
||||
@ -79,7 +79,7 @@ crate fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
|
||||
clauses
|
||||
}
|
||||
|
||||
crate fn merge_bounds(
|
||||
pub(crate) fn merge_bounds(
|
||||
cx: &clean::DocContext<'_>,
|
||||
bounds: &mut Vec<clean::GenericBound>,
|
||||
trait_did: DefId,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ use std::mem;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
crate fn krate(cx: &mut DocContext<'_>) -> Crate {
|
||||
pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
|
||||
let module = crate::visit_ast::RustdocVisitor::new(cx).visit();
|
||||
|
||||
for &cnum in cx.tcx.crates(()) {
|
||||
@ -75,7 +75,7 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
|
||||
Crate { module, primitives, external_traits: cx.external_traits.clone() }
|
||||
}
|
||||
|
||||
crate fn substs_to_args(
|
||||
pub(crate) fn substs_to_args(
|
||||
cx: &mut DocContext<'_>,
|
||||
substs: &[ty::subst::GenericArg<'_>],
|
||||
mut skip_first: bool,
|
||||
@ -146,7 +146,7 @@ pub(super) fn external_path(
|
||||
}
|
||||
|
||||
/// Remove the generic arguments from a path.
|
||||
crate fn strip_path_generics(mut path: Path) -> Path {
|
||||
pub(crate) fn strip_path_generics(mut path: Path) -> Path {
|
||||
for ps in path.segments.iter_mut() {
|
||||
ps.args = GenericArgs::AngleBracketed { args: vec![], bindings: ThinVec::new() }
|
||||
}
|
||||
@ -154,7 +154,7 @@ crate fn strip_path_generics(mut path: Path) -> Path {
|
||||
path
|
||||
}
|
||||
|
||||
crate fn qpath_to_string(p: &hir::QPath<'_>) -> String {
|
||||
pub(crate) fn qpath_to_string(p: &hir::QPath<'_>) -> String {
|
||||
let segments = match *p {
|
||||
hir::QPath::Resolved(_, path) => &path.segments,
|
||||
hir::QPath::TypeRelative(_, segment) => return segment.ident.to_string(),
|
||||
@ -173,7 +173,11 @@ crate fn qpath_to_string(p: &hir::QPath<'_>) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
crate fn build_deref_target_impls(cx: &mut DocContext<'_>, items: &[Item], ret: &mut Vec<Item>) {
|
||||
pub(crate) fn build_deref_target_impls(
|
||||
cx: &mut DocContext<'_>,
|
||||
items: &[Item],
|
||||
ret: &mut Vec<Item>,
|
||||
) {
|
||||
let tcx = cx.tcx;
|
||||
|
||||
for item in items {
|
||||
@ -196,7 +200,7 @@ crate fn build_deref_target_impls(cx: &mut DocContext<'_>, items: &[Item], ret:
|
||||
}
|
||||
}
|
||||
|
||||
crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
|
||||
pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
|
||||
use rustc_hir::*;
|
||||
debug!("trying to get a name from pattern: {:?}", p);
|
||||
|
||||
@ -229,7 +233,7 @@ crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
|
||||
})
|
||||
}
|
||||
|
||||
crate fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
|
||||
pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
|
||||
match n.val() {
|
||||
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) => {
|
||||
let mut s = if let Some(def) = def.as_local() {
|
||||
@ -259,7 +263,7 @@ crate fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn print_evaluated_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<String> {
|
||||
pub(crate) fn print_evaluated_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<String> {
|
||||
tcx.const_eval_poly(def_id).ok().and_then(|val| {
|
||||
let ty = tcx.type_of(def_id);
|
||||
match (val, ty.kind()) {
|
||||
@ -323,7 +327,7 @@ fn print_const_with_custom_print_scalar(tcx: TyCtxt<'_>, ct: ty::Const<'_>) -> S
|
||||
}
|
||||
}
|
||||
|
||||
crate fn is_literal_expr(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
||||
pub(crate) fn is_literal_expr(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
||||
if let hir::Node::Expr(expr) = tcx.hir().get(hir_id) {
|
||||
if let hir::ExprKind::Lit(_) = &expr.kind {
|
||||
return true;
|
||||
@ -339,7 +343,7 @@ crate fn is_literal_expr(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
crate fn print_const_expr(tcx: TyCtxt<'_>, body: hir::BodyId) -> String {
|
||||
pub(crate) fn print_const_expr(tcx: TyCtxt<'_>, body: hir::BodyId) -> String {
|
||||
let hir = tcx.hir();
|
||||
let value = &hir.body(body).value;
|
||||
|
||||
@ -353,7 +357,7 @@ crate fn print_const_expr(tcx: TyCtxt<'_>, body: hir::BodyId) -> String {
|
||||
}
|
||||
|
||||
/// Given a type Path, resolve it to a Type using the TyCtxt
|
||||
crate fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
|
||||
pub(crate) fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
|
||||
debug!("resolve_type({:?})", path);
|
||||
|
||||
match path.res {
|
||||
@ -367,7 +371,7 @@ crate fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn get_auto_trait_and_blanket_impls(
|
||||
pub(crate) fn get_auto_trait_and_blanket_impls(
|
||||
cx: &mut DocContext<'_>,
|
||||
item_def_id: DefId,
|
||||
) -> impl Iterator<Item = Item> {
|
||||
@ -389,7 +393,7 @@ crate fn get_auto_trait_and_blanket_impls(
|
||||
/// This is later used by [`href()`] to determine the HTML link for the item.
|
||||
///
|
||||
/// [`href()`]: crate::html::format::href
|
||||
crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
|
||||
pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
|
||||
use DefKind::*;
|
||||
debug!("register_res({:?})", res);
|
||||
|
||||
@ -428,14 +432,14 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
|
||||
did
|
||||
}
|
||||
|
||||
crate fn resolve_use_source(cx: &mut DocContext<'_>, path: Path) -> ImportSource {
|
||||
pub(crate) fn resolve_use_source(cx: &mut DocContext<'_>, path: Path) -> ImportSource {
|
||||
ImportSource {
|
||||
did: if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) },
|
||||
path,
|
||||
}
|
||||
}
|
||||
|
||||
crate fn enter_impl_trait<F, R>(cx: &mut DocContext<'_>, f: F) -> R
|
||||
pub(crate) fn enter_impl_trait<F, R>(cx: &mut DocContext<'_>, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut DocContext<'_>) -> R,
|
||||
{
|
||||
@ -447,7 +451,7 @@ where
|
||||
}
|
||||
|
||||
/// Find the nearest parent module of a [`DefId`].
|
||||
crate fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
||||
pub(crate) fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
||||
if def_id.is_top_level_module() {
|
||||
// The crate root has no parent. Use it as the root instead.
|
||||
Some(def_id)
|
||||
@ -474,7 +478,7 @@ crate fn find_nearest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<De
|
||||
///
|
||||
/// This function exists because it runs on `hir::Attributes` whereas the other is a
|
||||
/// `clean::Attributes` method.
|
||||
crate fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
|
||||
pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
|
||||
tcx.get_attrs(did, sym::doc).any(|attr| {
|
||||
attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag))
|
||||
})
|
||||
@ -484,7 +488,7 @@ crate fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
|
||||
/// so that the channel is consistent.
|
||||
///
|
||||
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
|
||||
crate const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
|
||||
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
|
||||
|
||||
/// Render a sequence of macro arms in a format suitable for displaying to the user
|
||||
/// as part of an item declaration.
|
||||
|
@ -31,7 +31,7 @@ use crate::scrape_examples::{AllCallLocations, ScrapeExamplesOptions};
|
||||
use crate::theme;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
crate enum OutputFormat {
|
||||
pub(crate) enum OutputFormat {
|
||||
Json,
|
||||
Html,
|
||||
}
|
||||
@ -43,7 +43,7 @@ impl Default for OutputFormat {
|
||||
}
|
||||
|
||||
impl OutputFormat {
|
||||
crate fn is_json(&self) -> bool {
|
||||
pub(crate) fn is_json(&self) -> bool {
|
||||
matches!(self, OutputFormat::Json)
|
||||
}
|
||||
}
|
||||
@ -62,100 +62,100 @@ impl TryFrom<&str> for OutputFormat {
|
||||
|
||||
/// Configuration options for rustdoc.
|
||||
#[derive(Clone)]
|
||||
crate struct Options {
|
||||
pub(crate) struct Options {
|
||||
// Basic options / Options passed directly to rustc
|
||||
/// The crate root or Markdown file to load.
|
||||
crate input: PathBuf,
|
||||
pub(crate) input: PathBuf,
|
||||
/// The name of the crate being documented.
|
||||
crate crate_name: Option<String>,
|
||||
pub(crate) crate_name: Option<String>,
|
||||
/// Whether or not this is a proc-macro crate
|
||||
crate proc_macro_crate: bool,
|
||||
pub(crate) proc_macro_crate: bool,
|
||||
/// How to format errors and warnings.
|
||||
crate error_format: ErrorOutputType,
|
||||
pub(crate) error_format: ErrorOutputType,
|
||||
/// Library search paths to hand to the compiler.
|
||||
crate libs: Vec<SearchPath>,
|
||||
pub(crate) libs: Vec<SearchPath>,
|
||||
/// Library search paths strings to hand to the compiler.
|
||||
crate lib_strs: Vec<String>,
|
||||
pub(crate) lib_strs: Vec<String>,
|
||||
/// The list of external crates to link against.
|
||||
crate externs: Externs,
|
||||
pub(crate) externs: Externs,
|
||||
/// The list of external crates strings to link against.
|
||||
crate extern_strs: Vec<String>,
|
||||
pub(crate) extern_strs: Vec<String>,
|
||||
/// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
|
||||
crate cfgs: Vec<String>,
|
||||
pub(crate) cfgs: Vec<String>,
|
||||
/// List of check cfg flags to hand to the compiler.
|
||||
crate check_cfgs: Vec<String>,
|
||||
pub(crate) check_cfgs: Vec<String>,
|
||||
/// Codegen options to hand to the compiler.
|
||||
crate codegen_options: CodegenOptions,
|
||||
pub(crate) codegen_options: CodegenOptions,
|
||||
/// Codegen options strings to hand to the compiler.
|
||||
crate codegen_options_strs: Vec<String>,
|
||||
pub(crate) codegen_options_strs: Vec<String>,
|
||||
/// Debugging (`-Z`) options to pass to the compiler.
|
||||
crate debugging_opts: DebuggingOptions,
|
||||
pub(crate) debugging_opts: DebuggingOptions,
|
||||
/// Debugging (`-Z`) options strings to pass to the compiler.
|
||||
crate debugging_opts_strs: Vec<String>,
|
||||
pub(crate) debugging_opts_strs: Vec<String>,
|
||||
/// The target used to compile the crate against.
|
||||
crate target: TargetTriple,
|
||||
pub(crate) target: TargetTriple,
|
||||
/// Edition used when reading the crate. Defaults to "2015". Also used by default when
|
||||
/// compiling doctests from the crate.
|
||||
crate edition: Edition,
|
||||
pub(crate) edition: Edition,
|
||||
/// The path to the sysroot. Used during the compilation process.
|
||||
crate maybe_sysroot: Option<PathBuf>,
|
||||
pub(crate) maybe_sysroot: Option<PathBuf>,
|
||||
/// Lint information passed over the command-line.
|
||||
crate lint_opts: Vec<(String, Level)>,
|
||||
pub(crate) lint_opts: Vec<(String, Level)>,
|
||||
/// Whether to ask rustc to describe the lints it knows.
|
||||
crate describe_lints: bool,
|
||||
pub(crate) describe_lints: bool,
|
||||
/// What level to cap lints at.
|
||||
crate lint_cap: Option<Level>,
|
||||
pub(crate) lint_cap: Option<Level>,
|
||||
|
||||
// Options specific to running doctests
|
||||
/// Whether we should run doctests instead of generating docs.
|
||||
crate should_test: bool,
|
||||
pub(crate) should_test: bool,
|
||||
/// List of arguments to pass to the test harness, if running tests.
|
||||
crate test_args: Vec<String>,
|
||||
pub(crate) test_args: Vec<String>,
|
||||
/// The working directory in which to run tests.
|
||||
crate test_run_directory: Option<PathBuf>,
|
||||
pub(crate) test_run_directory: Option<PathBuf>,
|
||||
/// Optional path to persist the doctest executables to, defaults to a
|
||||
/// temporary directory if not set.
|
||||
crate persist_doctests: Option<PathBuf>,
|
||||
pub(crate) persist_doctests: Option<PathBuf>,
|
||||
/// Runtool to run doctests with
|
||||
crate runtool: Option<String>,
|
||||
pub(crate) runtool: Option<String>,
|
||||
/// Arguments to pass to the runtool
|
||||
crate runtool_args: Vec<String>,
|
||||
pub(crate) runtool_args: Vec<String>,
|
||||
/// 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
|
||||
crate enable_per_target_ignores: bool,
|
||||
pub(crate) enable_per_target_ignores: bool,
|
||||
/// Do not run doctests, compile them if should_test is active.
|
||||
crate no_run: bool,
|
||||
pub(crate) no_run: bool,
|
||||
|
||||
/// The path to a rustc-like binary to build tests with. If not set, we
|
||||
/// default to loading from `$sysroot/bin/rustc`.
|
||||
crate test_builder: Option<PathBuf>,
|
||||
pub(crate) test_builder: Option<PathBuf>,
|
||||
|
||||
// Options that affect the documentation process
|
||||
/// Whether to run the `calculate-doc-coverage` pass, which counts the number of public items
|
||||
/// with and without documentation.
|
||||
crate show_coverage: bool,
|
||||
pub(crate) show_coverage: bool,
|
||||
|
||||
// Options that alter generated documentation pages
|
||||
/// Crate version to note on the sidebar of generated docs.
|
||||
crate crate_version: Option<String>,
|
||||
pub(crate) crate_version: Option<String>,
|
||||
/// Collected options specific to outputting final pages.
|
||||
crate render_options: RenderOptions,
|
||||
pub(crate) render_options: RenderOptions,
|
||||
/// The format that we output when rendering.
|
||||
///
|
||||
/// Currently used only for the `--show-coverage` option.
|
||||
crate output_format: OutputFormat,
|
||||
pub(crate) output_format: OutputFormat,
|
||||
/// If this option is set to `true`, rustdoc will only run checks and not generate
|
||||
/// documentation.
|
||||
crate run_check: bool,
|
||||
pub(crate) run_check: bool,
|
||||
/// Whether doctests should emit unused externs
|
||||
crate json_unused_externs: JsonUnusedExterns,
|
||||
pub(crate) json_unused_externs: JsonUnusedExterns,
|
||||
/// Whether to skip capturing stdout and stderr of tests.
|
||||
crate nocapture: bool,
|
||||
pub(crate) nocapture: bool,
|
||||
|
||||
/// Configuration for scraping examples from the current crate. If this option is Some(..) then
|
||||
/// the compiler will scrape examples and not generate documentation.
|
||||
crate scrape_examples_options: Option<ScrapeExamplesOptions>,
|
||||
pub(crate) scrape_examples_options: Option<ScrapeExamplesOptions>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Options {
|
||||
@ -205,83 +205,83 @@ impl fmt::Debug for Options {
|
||||
|
||||
/// Configuration options for the HTML page-creation process.
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct RenderOptions {
|
||||
pub(crate) struct RenderOptions {
|
||||
/// Output directory to generate docs into. Defaults to `doc`.
|
||||
crate output: PathBuf,
|
||||
pub(crate) output: PathBuf,
|
||||
/// External files to insert into generated pages.
|
||||
crate external_html: ExternalHtml,
|
||||
pub(crate) external_html: ExternalHtml,
|
||||
/// A pre-populated `IdMap` with the default headings and any headings added by Markdown files
|
||||
/// processed by `external_html`.
|
||||
crate id_map: IdMap,
|
||||
pub(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!
|
||||
crate playground_url: Option<String>,
|
||||
pub(crate) playground_url: Option<String>,
|
||||
/// 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.
|
||||
crate sort_modules_alphabetically: bool,
|
||||
pub(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.
|
||||
crate themes: Vec<StylePath>,
|
||||
pub(crate) themes: Vec<StylePath>,
|
||||
/// If present, CSS file that contains rules to add to the default CSS.
|
||||
crate extension_css: Option<PathBuf>,
|
||||
pub(crate) extension_css: Option<PathBuf>,
|
||||
/// A map of crate names to the URL to use instead of querying the crate's `html_root_url`.
|
||||
crate extern_html_root_urls: BTreeMap<String, String>,
|
||||
pub(crate) extern_html_root_urls: BTreeMap<String, String>,
|
||||
/// Whether to give precedence to `html_root_url` or `--exten-html-root-url`.
|
||||
crate extern_html_root_takes_precedence: bool,
|
||||
pub(crate) extern_html_root_takes_precedence: bool,
|
||||
/// A map of the default settings (values are as for DOM storage API). Keys should lack the
|
||||
/// `rustdoc-` prefix.
|
||||
crate default_settings: FxHashMap<String, String>,
|
||||
pub(crate) default_settings: FxHashMap<String, String>,
|
||||
/// If present, suffix added to CSS/JavaScript files when referencing them in generated pages.
|
||||
crate resource_suffix: String,
|
||||
pub(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.
|
||||
crate enable_minification: bool,
|
||||
pub(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.
|
||||
crate enable_index_page: bool,
|
||||
pub(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.
|
||||
crate index_page: Option<PathBuf>,
|
||||
pub(crate) index_page: Option<PathBuf>,
|
||||
/// An optional path to use as the location of static files. If not set, uses combinations of
|
||||
/// `../` to reach the documentation root.
|
||||
crate static_root_path: Option<String>,
|
||||
pub(crate) static_root_path: Option<String>,
|
||||
|
||||
// Options specific to reading standalone Markdown files
|
||||
/// Whether to generate a table of contents on the output file when reading a standalone
|
||||
/// Markdown file.
|
||||
crate markdown_no_toc: bool,
|
||||
pub(crate) markdown_no_toc: bool,
|
||||
/// Additional CSS files to link in pages generated from standalone Markdown files.
|
||||
crate markdown_css: Vec<String>,
|
||||
pub(crate) markdown_css: Vec<String>,
|
||||
/// 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.
|
||||
crate markdown_playground_url: Option<String>,
|
||||
pub(crate) markdown_playground_url: Option<String>,
|
||||
/// Document items that have lower than `pub` visibility.
|
||||
crate document_private: bool,
|
||||
pub(crate) document_private: bool,
|
||||
/// Document items that have `doc(hidden)`.
|
||||
crate document_hidden: bool,
|
||||
pub(crate) document_hidden: bool,
|
||||
/// If `true`, generate a JSON file in the crate folder instead of HTML redirection files.
|
||||
crate generate_redirect_map: bool,
|
||||
pub(crate) generate_redirect_map: bool,
|
||||
/// Show the memory layout of types in the docs.
|
||||
crate show_type_layout: bool,
|
||||
crate unstable_features: rustc_feature::UnstableFeatures,
|
||||
crate emit: Vec<EmitType>,
|
||||
pub(crate) show_type_layout: bool,
|
||||
pub(crate) unstable_features: rustc_feature::UnstableFeatures,
|
||||
pub(crate) emit: Vec<EmitType>,
|
||||
/// If `true`, HTML source pages will generate links for items to their definition.
|
||||
crate generate_link_to_definition: bool,
|
||||
pub(crate) generate_link_to_definition: bool,
|
||||
/// Set of function-call locations to include as examples
|
||||
crate call_locations: AllCallLocations,
|
||||
pub(crate) call_locations: AllCallLocations,
|
||||
/// If `true`, Context::init will not emit shared files.
|
||||
crate no_emit_shared: bool,
|
||||
pub(crate) no_emit_shared: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
crate enum EmitType {
|
||||
pub(crate) enum EmitType {
|
||||
Unversioned,
|
||||
Toolchain,
|
||||
InvocationSpecific,
|
||||
@ -302,7 +302,7 @@ impl FromStr for EmitType {
|
||||
}
|
||||
|
||||
impl RenderOptions {
|
||||
crate fn should_emit_crate(&self) -> bool {
|
||||
pub(crate) fn should_emit_crate(&self) -> bool {
|
||||
self.emit.is_empty() || self.emit.contains(&EmitType::InvocationSpecific)
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ impl RenderOptions {
|
||||
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.
|
||||
crate fn from_matches(matches: &getopts::Matches) -> Result<Options, i32> {
|
||||
pub(crate) fn from_matches(matches: &getopts::Matches) -> Result<Options, i32> {
|
||||
// Check for unstable options.
|
||||
nightly_options::check_nightly_options(matches, &opts());
|
||||
|
||||
@ -745,7 +745,7 @@ impl Options {
|
||||
}
|
||||
|
||||
/// Returns `true` if the file given as `self.input` is a Markdown file.
|
||||
crate fn markdown_input(&self) -> bool {
|
||||
pub(crate) fn markdown_input(&self) -> bool {
|
||||
self.input.extension().map_or(false, |e| e == "md" || e == "markdown")
|
||||
}
|
||||
}
|
||||
|
@ -32,70 +32,74 @@ use crate::formats::cache::Cache;
|
||||
use crate::passes::collect_intra_doc_links::PreprocessedMarkdownLink;
|
||||
use crate::passes::{self, Condition::*};
|
||||
|
||||
crate use rustc_session::config::{DebuggingOptions, Input, Options};
|
||||
pub(crate) use rustc_session::config::{DebuggingOptions, Input, Options};
|
||||
|
||||
crate struct ResolverCaches {
|
||||
crate markdown_links: Option<FxHashMap<String, Vec<PreprocessedMarkdownLink>>>,
|
||||
crate doc_link_resolutions: FxHashMap<(Symbol, Namespace, DefId), Option<Res<NodeId>>>,
|
||||
pub(crate) struct ResolverCaches {
|
||||
pub(crate) markdown_links: Option<FxHashMap<String, Vec<PreprocessedMarkdownLink>>>,
|
||||
pub(crate) doc_link_resolutions: FxHashMap<(Symbol, Namespace, DefId), Option<Res<NodeId>>>,
|
||||
/// Traits in scope for a given module.
|
||||
/// See `collect_intra_doc_links::traits_implemented_by` for more details.
|
||||
crate traits_in_scope: DefIdMap<Vec<TraitCandidate>>,
|
||||
crate all_traits: Option<Vec<DefId>>,
|
||||
crate all_trait_impls: Option<Vec<DefId>>,
|
||||
crate all_macro_rules: FxHashMap<Symbol, Res<NodeId>>,
|
||||
pub(crate) traits_in_scope: DefIdMap<Vec<TraitCandidate>>,
|
||||
pub(crate) all_traits: Option<Vec<DefId>>,
|
||||
pub(crate) all_trait_impls: Option<Vec<DefId>>,
|
||||
pub(crate) all_macro_rules: FxHashMap<Symbol, Res<NodeId>>,
|
||||
}
|
||||
|
||||
crate struct DocContext<'tcx> {
|
||||
crate tcx: TyCtxt<'tcx>,
|
||||
pub(crate) struct DocContext<'tcx> {
|
||||
pub(crate) tcx: TyCtxt<'tcx>,
|
||||
/// Name resolver. Used for intra-doc links.
|
||||
///
|
||||
/// The `Rc<RefCell<...>>` wrapping is needed because that is what's returned by
|
||||
/// [`rustc_interface::Queries::expansion()`].
|
||||
// FIXME: see if we can get rid of this RefCell somehow
|
||||
crate resolver: Rc<RefCell<interface::BoxedResolver>>,
|
||||
crate resolver_caches: ResolverCaches,
|
||||
pub(crate) resolver: Rc<RefCell<interface::BoxedResolver>>,
|
||||
pub(crate) resolver_caches: ResolverCaches,
|
||||
/// Used for normalization.
|
||||
///
|
||||
/// Most of this logic is copied from rustc_lint::late.
|
||||
crate param_env: ParamEnv<'tcx>,
|
||||
pub(crate) param_env: ParamEnv<'tcx>,
|
||||
/// Later on moved through `clean::Crate` into `cache`
|
||||
crate external_traits: Rc<RefCell<FxHashMap<DefId, clean::TraitWithExtraInfo>>>,
|
||||
pub(crate) external_traits: Rc<RefCell<FxHashMap<DefId, clean::TraitWithExtraInfo>>>,
|
||||
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
|
||||
/// the same time.
|
||||
crate active_extern_traits: FxHashSet<DefId>,
|
||||
pub(crate) active_extern_traits: FxHashSet<DefId>,
|
||||
// The current set of parameter substitutions,
|
||||
// for expanding type aliases at the HIR level:
|
||||
/// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const
|
||||
crate substs: FxHashMap<DefId, clean::SubstParam>,
|
||||
pub(crate) substs: FxHashMap<DefId, clean::SubstParam>,
|
||||
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds
|
||||
crate impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>,
|
||||
pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>,
|
||||
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
|
||||
// FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
|
||||
crate generated_synthetics: FxHashSet<(Ty<'tcx>, DefId)>,
|
||||
crate auto_traits: Vec<DefId>,
|
||||
pub(crate) generated_synthetics: FxHashSet<(Ty<'tcx>, DefId)>,
|
||||
pub(crate) auto_traits: Vec<DefId>,
|
||||
/// The options given to rustdoc that could be relevant to a pass.
|
||||
crate render_options: RenderOptions,
|
||||
pub(crate) render_options: RenderOptions,
|
||||
/// This same cache is used throughout rustdoc, including in [`crate::html::render`].
|
||||
crate cache: Cache,
|
||||
pub(crate) cache: Cache,
|
||||
/// Used by [`clean::inline`] to tell if an item has already been inlined.
|
||||
crate inlined: FxHashSet<ItemId>,
|
||||
pub(crate) inlined: FxHashSet<ItemId>,
|
||||
/// Used by `calculate_doc_coverage`.
|
||||
crate output_format: OutputFormat,
|
||||
pub(crate) output_format: OutputFormat,
|
||||
}
|
||||
|
||||
impl<'tcx> DocContext<'tcx> {
|
||||
crate fn sess(&self) -> &'tcx Session {
|
||||
pub(crate) fn sess(&self) -> &'tcx Session {
|
||||
self.tcx.sess
|
||||
}
|
||||
|
||||
crate fn with_param_env<T, F: FnOnce(&mut Self) -> T>(&mut self, def_id: DefId, f: F) -> T {
|
||||
pub(crate) fn with_param_env<T, F: FnOnce(&mut Self) -> T>(
|
||||
&mut self,
|
||||
def_id: DefId,
|
||||
f: F,
|
||||
) -> T {
|
||||
let old_param_env = mem::replace(&mut self.param_env, self.tcx.param_env(def_id));
|
||||
let ret = f(self);
|
||||
self.param_env = old_param_env;
|
||||
ret
|
||||
}
|
||||
|
||||
crate fn enter_resolver<F, R>(&self, f: F) -> R
|
||||
pub(crate) fn enter_resolver<F, R>(&self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut resolve::Resolver<'_>) -> R,
|
||||
{
|
||||
@ -104,7 +108,11 @@ impl<'tcx> DocContext<'tcx> {
|
||||
|
||||
/// Call the closure with the given parameters set as
|
||||
/// the substitutions for a type alias' RHS.
|
||||
crate fn enter_alias<F, R>(&mut self, substs: FxHashMap<DefId, clean::SubstParam>, f: F) -> R
|
||||
pub(crate) fn enter_alias<F, R>(
|
||||
&mut self,
|
||||
substs: FxHashMap<DefId, clean::SubstParam>,
|
||||
f: F,
|
||||
) -> R
|
||||
where
|
||||
F: FnOnce(&mut Self) -> R,
|
||||
{
|
||||
@ -116,7 +124,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.)
|
||||
crate fn as_local_hir_id(tcx: TyCtxt<'_>, item_id: ItemId) -> Option<HirId> {
|
||||
pub(crate) fn as_local_hir_id(tcx: TyCtxt<'_>, item_id: ItemId) -> Option<HirId> {
|
||||
match item_id {
|
||||
ItemId::DefId(real_id) => {
|
||||
real_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
@ -126,13 +134,13 @@ impl<'tcx> DocContext<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn with_all_traits(&mut self, f: impl FnOnce(&mut Self, &[DefId])) {
|
||||
pub(crate) fn with_all_traits(&mut self, f: impl FnOnce(&mut Self, &[DefId])) {
|
||||
let all_traits = self.resolver_caches.all_traits.take();
|
||||
f(self, all_traits.as_ref().expect("`all_traits` are already borrowed"));
|
||||
self.resolver_caches.all_traits = all_traits;
|
||||
}
|
||||
|
||||
crate fn with_all_trait_impls(&mut self, f: impl FnOnce(&mut Self, &[DefId])) {
|
||||
pub(crate) fn with_all_trait_impls(&mut self, f: impl FnOnce(&mut Self, &[DefId])) {
|
||||
let all_trait_impls = self.resolver_caches.all_trait_impls.take();
|
||||
f(self, all_trait_impls.as_ref().expect("`all_trait_impls` are already borrowed"));
|
||||
self.resolver_caches.all_trait_impls = all_trait_impls;
|
||||
@ -143,7 +151,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.
|
||||
crate fn new_handler(
|
||||
pub(crate) fn new_handler(
|
||||
error_format: ErrorOutputType,
|
||||
source_map: Option<Lrc<source_map::SourceMap>>,
|
||||
debugging_opts: &DebuggingOptions,
|
||||
@ -194,7 +202,7 @@ crate fn new_handler(
|
||||
}
|
||||
|
||||
/// Parse, resolve, and typecheck the given crate.
|
||||
crate fn create_config(
|
||||
pub(crate) fn create_config(
|
||||
RustdocOptions {
|
||||
input,
|
||||
crate_name,
|
||||
@ -311,7 +319,7 @@ crate fn create_config(
|
||||
}
|
||||
}
|
||||
|
||||
crate fn run_global_ctxt(
|
||||
pub(crate) fn run_global_ctxt(
|
||||
tcx: TyCtxt<'_>,
|
||||
resolver: Rc<RefCell<interface::BoxedResolver>>,
|
||||
resolver_caches: ResolverCaches,
|
||||
@ -535,7 +543,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)]
|
||||
crate enum ImplTraitParam {
|
||||
pub(crate) enum ImplTraitParam {
|
||||
DefId(DefId),
|
||||
ParamIndex(u32),
|
||||
}
|
||||
|
@ -15,38 +15,38 @@ use std::path::{Path, PathBuf};
|
||||
use std::string::ToString;
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
crate trait PathError {
|
||||
pub(crate) trait PathError {
|
||||
fn new<S, P: AsRef<Path>>(e: S, path: P) -> Self
|
||||
where
|
||||
S: ToString + Sized;
|
||||
}
|
||||
|
||||
crate struct DocFS {
|
||||
pub(crate) struct DocFS {
|
||||
sync_only: bool,
|
||||
errors: Option<Sender<String>>,
|
||||
}
|
||||
|
||||
impl DocFS {
|
||||
crate fn new(errors: Sender<String>) -> DocFS {
|
||||
pub(crate) fn new(errors: Sender<String>) -> DocFS {
|
||||
DocFS { sync_only: false, errors: Some(errors) }
|
||||
}
|
||||
|
||||
crate fn set_sync_only(&mut self, sync_only: bool) {
|
||||
pub(crate) fn set_sync_only(&mut self, sync_only: bool) {
|
||||
self.sync_only = sync_only;
|
||||
}
|
||||
|
||||
crate fn close(&mut self) {
|
||||
pub(crate) fn close(&mut self) {
|
||||
self.errors = None;
|
||||
}
|
||||
|
||||
crate fn create_dir_all<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
|
||||
pub(crate) fn create_dir_all<P: AsRef<Path>>(&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)
|
||||
}
|
||||
|
||||
crate fn write<E>(
|
||||
pub(crate) fn write<E>(
|
||||
&self,
|
||||
path: PathBuf,
|
||||
contents: impl 'static + Send + AsRef<[u8]>,
|
||||
|
@ -40,14 +40,14 @@ use crate::passes::span_of_attrs;
|
||||
|
||||
/// Options that apply to all doctests in a crate or Markdown file (for `rustdoc foo.md`).
|
||||
#[derive(Clone, Default)]
|
||||
crate struct GlobalTestOptions {
|
||||
pub(crate) struct GlobalTestOptions {
|
||||
/// Whether to disable the default `extern crate my_crate;` when creating doctests.
|
||||
crate no_crate_inject: bool,
|
||||
pub(crate) no_crate_inject: bool,
|
||||
/// Additional crate-level attributes to add to doctests.
|
||||
crate attrs: Vec<String>,
|
||||
pub(crate) attrs: Vec<String>,
|
||||
}
|
||||
|
||||
crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
|
||||
pub(crate) fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
|
||||
let input = config::Input::File(options.input.clone());
|
||||
|
||||
let invalid_codeblock_attributes_name = crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
@ -207,7 +207,11 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
crate fn run_tests(mut test_args: Vec<String>, nocapture: bool, tests: Vec<test::TestDescAndFn>) {
|
||||
pub(crate) fn run_tests(
|
||||
mut test_args: Vec<String>,
|
||||
nocapture: bool,
|
||||
tests: Vec<test::TestDescAndFn>,
|
||||
) {
|
||||
test_args.insert(0, "rustdoctest".to_string());
|
||||
if nocapture {
|
||||
test_args.push("--nocapture".to_string());
|
||||
@ -488,7 +492,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 as well as if the output stream supports colors or not.
|
||||
crate fn make_test(
|
||||
pub(crate) fn make_test(
|
||||
s: &str,
|
||||
crate_name: Option<&str>,
|
||||
dont_insert_main: bool,
|
||||
@ -840,7 +844,7 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
|
||||
(before, after, crates)
|
||||
}
|
||||
|
||||
crate trait Tester {
|
||||
pub(crate) trait Tester {
|
||||
fn add_test(&mut self, test: String, config: LangString, line: usize);
|
||||
fn get_line(&self) -> usize {
|
||||
0
|
||||
@ -848,8 +852,8 @@ crate trait Tester {
|
||||
fn register_header(&mut self, _name: &str, _level: u32) {}
|
||||
}
|
||||
|
||||
crate struct Collector {
|
||||
crate tests: Vec<test::TestDescAndFn>,
|
||||
pub(crate) struct Collector {
|
||||
pub(crate) tests: Vec<test::TestDescAndFn>,
|
||||
|
||||
// The name of the test displayed to the user, separated by `::`.
|
||||
//
|
||||
@ -887,7 +891,7 @@ crate struct Collector {
|
||||
}
|
||||
|
||||
impl Collector {
|
||||
crate fn new(
|
||||
pub(crate) fn new(
|
||||
crate_name: Symbol,
|
||||
rustdoc_options: RustdocOptions,
|
||||
use_headers: bool,
|
||||
@ -922,7 +926,7 @@ impl Collector {
|
||||
format!("{} - {}(line {})", filename.prefer_local(), item_path, line)
|
||||
}
|
||||
|
||||
crate fn set_position(&mut self, position: Span) {
|
||||
pub(crate) fn set_position(&mut self, position: Span) {
|
||||
self.position = position;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ use std::path::{Path, PathBuf};
|
||||
use crate::docfs::PathError;
|
||||
|
||||
#[derive(Debug)]
|
||||
crate struct Error {
|
||||
crate file: PathBuf,
|
||||
crate error: String,
|
||||
pub(crate) struct Error {
|
||||
pub(crate) file: PathBuf,
|
||||
pub(crate) error: String,
|
||||
}
|
||||
|
||||
impl error::Error for Error {}
|
||||
|
@ -7,20 +7,20 @@ use std::str;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
crate struct ExternalHtml {
|
||||
pub(crate) struct ExternalHtml {
|
||||
/// Content that will be included inline in the `<head>` section of a
|
||||
/// rendered Markdown file or generated documentation
|
||||
crate in_header: String,
|
||||
pub(crate) in_header: String,
|
||||
/// Content that will be included inline between `<body>` and the content of
|
||||
/// a rendered Markdown file or generated documentation
|
||||
crate before_content: String,
|
||||
pub(crate) before_content: String,
|
||||
/// Content that will be included inline between the content and `</body>` of
|
||||
/// a rendered Markdown file or generated documentation
|
||||
crate after_content: String,
|
||||
pub(crate) after_content: String,
|
||||
}
|
||||
|
||||
impl ExternalHtml {
|
||||
crate fn load(
|
||||
pub(crate) fn load(
|
||||
in_header: &[String],
|
||||
before_content: &[String],
|
||||
after_content: &[String],
|
||||
@ -70,12 +70,12 @@ impl ExternalHtml {
|
||||
}
|
||||
}
|
||||
|
||||
crate enum LoadStringError {
|
||||
pub(crate) enum LoadStringError {
|
||||
ReadFail,
|
||||
BadUtf8,
|
||||
}
|
||||
|
||||
crate fn load_string<P: AsRef<Path>>(
|
||||
pub(crate) fn load_string<P: AsRef<Path>>(
|
||||
file_path: P,
|
||||
diag: &rustc_errors::Handler,
|
||||
) -> Result<String, LoadStringError> {
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::clean::*;
|
||||
|
||||
crate fn strip_item(mut item: Item) -> Item {
|
||||
pub(crate) fn strip_item(mut item: Item) -> Item {
|
||||
if !matches!(*item.kind, StrippedItem(..)) {
|
||||
item.kind = box StrippedItem(item.kind);
|
||||
}
|
||||
item
|
||||
}
|
||||
|
||||
crate trait DocFolder: Sized {
|
||||
pub(crate) trait DocFolder: Sized {
|
||||
fn fold_item(&mut self, item: Item) -> Option<Item> {
|
||||
Some(self.fold_item_recur(item))
|
||||
}
|
||||
|
@ -26,25 +26,25 @@ use crate::html::render::IndexItem;
|
||||
/// to `Send` so it may be stored in an `Arc` instance and shared among the various
|
||||
/// rendering threads.
|
||||
#[derive(Default)]
|
||||
crate struct Cache {
|
||||
pub(crate) struct Cache {
|
||||
/// Maps a type ID to all known implementations for that type. This is only
|
||||
/// recognized for intra-crate [`clean::Type::Path`]s, 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.
|
||||
crate impls: FxHashMap<DefId, Vec<Impl>>,
|
||||
pub(crate) impls: FxHashMap<DefId, Vec<Impl>>,
|
||||
|
||||
/// 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.
|
||||
crate paths: FxHashMap<DefId, (Vec<Symbol>, ItemType)>,
|
||||
pub(crate) paths: FxHashMap<DefId, (Vec<Symbol>, ItemType)>,
|
||||
|
||||
/// Similar to `paths`, but only holds external paths. This is only used for
|
||||
/// generating explicit hyperlinks to other crates.
|
||||
crate external_paths: FxHashMap<DefId, (Vec<Symbol>, ItemType)>,
|
||||
pub(crate) external_paths: FxHashMap<DefId, (Vec<Symbol>, ItemType)>,
|
||||
|
||||
/// Maps local `DefId`s of exported types to fully qualified paths.
|
||||
/// Unlike 'paths', this mapping ignores any renames that occur
|
||||
@ -56,41 +56,41 @@ crate 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.
|
||||
crate exact_paths: FxHashMap<DefId, Vec<Symbol>>,
|
||||
pub(crate) exact_paths: FxHashMap<DefId, Vec<Symbol>>,
|
||||
|
||||
/// 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.
|
||||
crate traits: FxHashMap<DefId, clean::TraitWithExtraInfo>,
|
||||
pub(crate) traits: FxHashMap<DefId, clean::TraitWithExtraInfo>,
|
||||
|
||||
/// 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
|
||||
crate implementors: FxHashMap<DefId, Vec<Impl>>,
|
||||
pub(crate) implementors: FxHashMap<DefId, Vec<Impl>>,
|
||||
|
||||
/// Cache of where external crate documentation can be found.
|
||||
crate extern_locations: FxHashMap<CrateNum, ExternalLocation>,
|
||||
pub(crate) extern_locations: FxHashMap<CrateNum, ExternalLocation>,
|
||||
|
||||
/// Cache of where documentation for primitives can be found.
|
||||
crate primitive_locations: FxHashMap<clean::PrimitiveType, DefId>,
|
||||
pub(crate) primitive_locations: FxHashMap<clean::PrimitiveType, DefId>,
|
||||
|
||||
// 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.
|
||||
crate access_levels: AccessLevels<DefId>,
|
||||
pub(crate) access_levels: AccessLevels<DefId>,
|
||||
|
||||
/// The version of the crate being documented, if given from the `--crate-version` flag.
|
||||
crate crate_version: Option<String>,
|
||||
pub(crate) crate_version: Option<String>,
|
||||
|
||||
/// Whether to document private items.
|
||||
/// This is stored in `Cache` so it doesn't need to be passed through all rustdoc functions.
|
||||
crate document_private: bool,
|
||||
pub(crate) document_private: bool,
|
||||
|
||||
/// Crates marked with [`#[doc(masked)]`][doc_masked].
|
||||
///
|
||||
/// [doc_masked]: https://doc.rust-lang.org/nightly/unstable-book/language-features/doc-masked.html
|
||||
crate masked_crates: FxHashSet<CrateNum>,
|
||||
pub(crate) masked_crates: FxHashSet<CrateNum>,
|
||||
|
||||
// Private fields only used when initially crawling a crate to build a cache
|
||||
stack: Vec<Symbol>,
|
||||
@ -98,14 +98,14 @@ crate struct Cache {
|
||||
parent_is_trait_impl: bool,
|
||||
stripped_mod: bool,
|
||||
|
||||
crate search_index: Vec<IndexItem>,
|
||||
pub(crate) search_index: Vec<IndexItem>,
|
||||
|
||||
// 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.
|
||||
crate orphan_impl_items: Vec<(DefId, clean::Item)>,
|
||||
pub(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
|
||||
@ -119,9 +119,9 @@ crate struct Cache {
|
||||
/// All intra-doc links resolved so far.
|
||||
///
|
||||
/// Links are indexed by the DefId of the item they document.
|
||||
crate intra_doc_links: FxHashMap<ItemId, Vec<clean::ItemLink>>,
|
||||
pub(crate) intra_doc_links: FxHashMap<ItemId, Vec<clean::ItemLink>>,
|
||||
/// Cfg that have been hidden via #![doc(cfg_hide(...))]
|
||||
crate hidden_cfg: FxHashSet<clean::cfg::Cfg>,
|
||||
pub(crate) hidden_cfg: FxHashSet<clean::cfg::Cfg>,
|
||||
}
|
||||
|
||||
/// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`.
|
||||
@ -133,13 +133,13 @@ struct CacheBuilder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
crate fn new(access_levels: AccessLevels<DefId>, document_private: bool) -> Self {
|
||||
pub(crate) fn new(access_levels: AccessLevels<DefId>, document_private: bool) -> Self {
|
||||
Cache { access_levels, document_private, ..Cache::default() }
|
||||
}
|
||||
|
||||
/// Populates the `Cache` with more data. The returned `Crate` will be missing some data that was
|
||||
/// in `krate` due to the data being moved into the `Cache`.
|
||||
crate fn populate(cx: &mut DocContext<'_>, mut krate: clean::Crate) -> clean::Crate {
|
||||
pub(crate) fn populate(cx: &mut DocContext<'_>, mut krate: clean::Crate) -> clean::Crate {
|
||||
let tcx = cx.tcx;
|
||||
|
||||
// Crawl the crate to build various caches used for the output
|
||||
|
@ -21,7 +21,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, Hash, Clone, Debug, PartialOrd, Ord)]
|
||||
crate enum ItemType {
|
||||
pub(crate) enum ItemType {
|
||||
Module = 0,
|
||||
ExternCrate = 1,
|
||||
Import = 2,
|
||||
@ -147,7 +147,7 @@ impl From<DefKind> for ItemType {
|
||||
}
|
||||
|
||||
impl ItemType {
|
||||
crate fn as_str(&self) -> &'static str {
|
||||
pub(crate) fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
ItemType::Module => "mod",
|
||||
ItemType::ExternCrate => "externcrate",
|
||||
|
@ -1,16 +1,16 @@
|
||||
crate mod cache;
|
||||
crate mod item_type;
|
||||
crate mod renderer;
|
||||
pub(crate) mod cache;
|
||||
pub(crate) mod item_type;
|
||||
pub(crate) mod renderer;
|
||||
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
||||
crate use renderer::{run_format, FormatRenderer};
|
||||
pub(crate) use renderer::{run_format, FormatRenderer};
|
||||
|
||||
use crate::clean::{self, ItemId};
|
||||
|
||||
/// Specifies whether rendering directly implemented trait items or ones from a certain Deref
|
||||
/// impl.
|
||||
crate enum AssocItemRender<'a> {
|
||||
pub(crate) enum AssocItemRender<'a> {
|
||||
All,
|
||||
DerefFor { trait_: &'a clean::Path, type_: &'a clean::Type, deref_mut_: bool },
|
||||
}
|
||||
@ -18,26 +18,26 @@ crate 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)]
|
||||
crate enum RenderMode {
|
||||
pub(crate) enum RenderMode {
|
||||
Normal,
|
||||
ForDeref { mut_: bool },
|
||||
}
|
||||
|
||||
/// Metadata about implementations for a type or trait.
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct Impl {
|
||||
crate impl_item: clean::Item,
|
||||
pub(crate) struct Impl {
|
||||
pub(crate) impl_item: clean::Item,
|
||||
}
|
||||
|
||||
impl Impl {
|
||||
crate fn inner_impl(&self) -> &clean::Impl {
|
||||
pub(crate) fn inner_impl(&self) -> &clean::Impl {
|
||||
match *self.impl_item.kind {
|
||||
clean::ImplItem(ref impl_) => impl_,
|
||||
_ => panic!("non-impl item found in impl"),
|
||||
}
|
||||
}
|
||||
|
||||
crate fn trait_did(&self) -> Option<DefId> {
|
||||
pub(crate) fn trait_did(&self) -> Option<DefId> {
|
||||
self.inner_impl().trait_.as_ref().map(|t| t.def_id())
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ impl Impl {
|
||||
/// with blanket impls).
|
||||
///
|
||||
/// It panics if `self` is a `ItemId::Primitive`.
|
||||
crate fn def_id(&self) -> DefId {
|
||||
pub(crate) fn def_id(&self) -> DefId {
|
||||
match self.impl_item.item_id {
|
||||
ItemId::Blanket { impl_id, .. } => impl_id,
|
||||
ItemId::Auto { trait_, .. } => trait_,
|
||||
|
@ -9,7 +9,7 @@ use crate::formats::cache::Cache;
|
||||
/// 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.
|
||||
crate trait FormatRenderer<'tcx>: Sized {
|
||||
pub(crate) trait FormatRenderer<'tcx>: Sized {
|
||||
/// Gives a description of the renderer. Used for performance profiling.
|
||||
fn descr() -> &'static str;
|
||||
|
||||
@ -48,7 +48,7 @@ crate trait FormatRenderer<'tcx>: Sized {
|
||||
}
|
||||
|
||||
/// Main method for rendering a crate.
|
||||
crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||
pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||
krate: clean::Crate,
|
||||
options: RenderOptions,
|
||||
cache: Cache,
|
||||
|
@ -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.
|
||||
crate struct Escape<'a>(pub &'a str);
|
||||
pub(crate) struct Escape<'a>(pub &'a str);
|
||||
|
||||
impl<'a> fmt::Display for Escape<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
@ -33,7 +33,7 @@ use crate::html::render::Context;
|
||||
use super::url_parts_builder::estimate_item_path_byte_length;
|
||||
use super::url_parts_builder::UrlPartsBuilder;
|
||||
|
||||
crate trait Print {
|
||||
pub(crate) trait Print {
|
||||
fn print(self, buffer: &mut Buffer);
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ impl Print for &'_ str {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
crate struct Buffer {
|
||||
pub(crate) struct Buffer {
|
||||
for_html: bool,
|
||||
buffer: String,
|
||||
}
|
||||
@ -82,63 +82,63 @@ impl core::fmt::Write for Buffer {
|
||||
}
|
||||
|
||||
impl Buffer {
|
||||
crate fn empty_from(v: &Buffer) -> Buffer {
|
||||
pub(crate) fn empty_from(v: &Buffer) -> Buffer {
|
||||
Buffer { for_html: v.for_html, buffer: String::new() }
|
||||
}
|
||||
|
||||
crate fn html() -> Buffer {
|
||||
pub(crate) fn html() -> Buffer {
|
||||
Buffer { for_html: true, buffer: String::new() }
|
||||
}
|
||||
|
||||
crate fn new() -> Buffer {
|
||||
pub(crate) fn new() -> Buffer {
|
||||
Buffer { for_html: false, buffer: String::new() }
|
||||
}
|
||||
|
||||
crate fn is_empty(&self) -> bool {
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.buffer.is_empty()
|
||||
}
|
||||
|
||||
crate fn into_inner(self) -> String {
|
||||
pub(crate) fn into_inner(self) -> String {
|
||||
self.buffer
|
||||
}
|
||||
|
||||
crate fn insert_str(&mut self, idx: usize, s: &str) {
|
||||
pub(crate) fn insert_str(&mut self, idx: usize, s: &str) {
|
||||
self.buffer.insert_str(idx, s);
|
||||
}
|
||||
|
||||
crate fn push_str(&mut self, s: &str) {
|
||||
pub(crate) fn push_str(&mut self, s: &str) {
|
||||
self.buffer.push_str(s);
|
||||
}
|
||||
|
||||
crate fn push_buffer(&mut self, other: Buffer) {
|
||||
pub(crate) fn push_buffer(&mut self, other: Buffer) {
|
||||
self.buffer.push_str(&other.buffer);
|
||||
}
|
||||
|
||||
// Intended for consumption by write! and writeln! (std::fmt) but without
|
||||
// the fmt::Result return type imposed by fmt::Write (and avoiding the trait
|
||||
// import).
|
||||
crate fn write_str(&mut self, s: &str) {
|
||||
pub(crate) fn write_str(&mut self, s: &str) {
|
||||
self.buffer.push_str(s);
|
||||
}
|
||||
|
||||
// Intended for consumption by write! and writeln! (std::fmt) but without
|
||||
// the fmt::Result return type imposed by fmt::Write (and avoiding the trait
|
||||
// import).
|
||||
crate fn write_fmt(&mut self, v: fmt::Arguments<'_>) {
|
||||
pub(crate) fn write_fmt(&mut self, v: fmt::Arguments<'_>) {
|
||||
use fmt::Write;
|
||||
self.buffer.write_fmt(v).unwrap();
|
||||
}
|
||||
|
||||
crate fn to_display<T: Print>(mut self, t: T) -> String {
|
||||
pub(crate) fn to_display<T: Print>(mut self, t: T) -> String {
|
||||
t.print(&mut self);
|
||||
self.into_inner()
|
||||
}
|
||||
|
||||
crate fn is_for_html(&self) -> bool {
|
||||
pub(crate) fn is_for_html(&self) -> bool {
|
||||
self.for_html
|
||||
}
|
||||
|
||||
crate fn reserve(&mut self, additional: usize) {
|
||||
pub(crate) fn reserve(&mut self, additional: usize) {
|
||||
self.buffer.reserve(additional)
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ fn comma_sep<T: fmt::Display>(
|
||||
})
|
||||
}
|
||||
|
||||
crate fn print_generic_bounds<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print_generic_bounds<'a, 'tcx: 'a>(
|
||||
bounds: &'a [clean::GenericBound],
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -176,7 +176,7 @@ crate fn print_generic_bounds<'a, 'tcx: 'a>(
|
||||
}
|
||||
|
||||
impl clean::GenericParamDef {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -239,7 +239,7 @@ impl clean::GenericParamDef {
|
||||
}
|
||||
|
||||
impl clean::Generics {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -262,7 +262,7 @@ impl clean::Generics {
|
||||
/// * The Generics from which to emit a where-clause.
|
||||
/// * The number of spaces to indent each line with.
|
||||
/// * Whether the where-clause needs to add a comma and newline after the last bound.
|
||||
crate fn print_where_clause<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
|
||||
gens: &'a clean::Generics,
|
||||
cx: &'a Context<'tcx>,
|
||||
indent: usize,
|
||||
@ -372,13 +372,13 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
|
||||
}
|
||||
|
||||
impl clean::Lifetime {
|
||||
crate fn print(&self) -> impl fmt::Display + '_ {
|
||||
pub(crate) fn print(&self) -> impl fmt::Display + '_ {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl clean::Constant {
|
||||
crate fn print(&self, tcx: TyCtxt<'_>) -> impl fmt::Display + '_ {
|
||||
pub(crate) fn print(&self, tcx: TyCtxt<'_>) -> impl fmt::Display + '_ {
|
||||
let expr = self.expr(tcx);
|
||||
display_fn(
|
||||
move |f| {
|
||||
@ -419,7 +419,7 @@ impl clean::PolyTrait {
|
||||
}
|
||||
|
||||
impl clean::GenericBound {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -516,7 +516,7 @@ impl clean::GenericArgs {
|
||||
}
|
||||
|
||||
// Possible errors when computing href link source for a `DefId`
|
||||
crate enum HrefError {
|
||||
pub(crate) enum HrefError {
|
||||
/// This item is known to rustdoc, but from a crate that does not have documentation generated.
|
||||
///
|
||||
/// This can only happen for non-local items.
|
||||
@ -543,7 +543,7 @@ crate enum HrefError {
|
||||
}
|
||||
|
||||
// Panics if `syms` is empty.
|
||||
crate fn join_with_double_colon(syms: &[Symbol]) -> String {
|
||||
pub(crate) fn join_with_double_colon(syms: &[Symbol]) -> String {
|
||||
let mut s = String::with_capacity(estimate_item_path_byte_length(syms.len()));
|
||||
s.push_str(&syms[0].as_str());
|
||||
for sym in &syms[1..] {
|
||||
@ -553,7 +553,7 @@ crate fn join_with_double_colon(syms: &[Symbol]) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
crate fn href_with_root_path(
|
||||
pub(crate) fn href_with_root_path(
|
||||
did: DefId,
|
||||
cx: &Context<'_>,
|
||||
root_path: Option<&str>,
|
||||
@ -633,14 +633,17 @@ crate fn href_with_root_path(
|
||||
Ok((url_parts.finish(), shortty, fqp.to_vec()))
|
||||
}
|
||||
|
||||
crate fn href(did: DefId, cx: &Context<'_>) -> Result<(String, ItemType, Vec<Symbol>), HrefError> {
|
||||
pub(crate) fn href(
|
||||
did: DefId,
|
||||
cx: &Context<'_>,
|
||||
) -> Result<(String, ItemType, Vec<Symbol>), HrefError> {
|
||||
href_with_root_path(did, cx, None)
|
||||
}
|
||||
|
||||
/// Both paths should only be modules.
|
||||
/// This is because modules get their own directories; that is, `std::vec` and `std::vec::Vec` will
|
||||
/// both need `../iter/trait.Iterator.html` to get at the iterator trait.
|
||||
crate fn href_relative_parts<'fqp>(
|
||||
pub(crate) fn href_relative_parts<'fqp>(
|
||||
fqp: &'fqp [Symbol],
|
||||
relative_to_fqp: &[Symbol],
|
||||
) -> Box<dyn Iterator<Item = Symbol> + 'fqp> {
|
||||
@ -787,7 +790,7 @@ fn tybounds<'a, 'tcx: 'a>(
|
||||
})
|
||||
}
|
||||
|
||||
crate fn anchor<'a, 'cx: 'a>(
|
||||
pub(crate) fn anchor<'a, 'cx: 'a>(
|
||||
did: DefId,
|
||||
text: Symbol,
|
||||
cx: &'cx Context<'_>,
|
||||
@ -1031,7 +1034,7 @@ fn fmt_type<'cx>(
|
||||
}
|
||||
|
||||
impl clean::Type {
|
||||
crate fn print<'b, 'a: 'b, 'tcx: 'a>(
|
||||
pub(crate) fn print<'b, 'a: 'b, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'b + Captures<'tcx> {
|
||||
@ -1040,7 +1043,7 @@ impl clean::Type {
|
||||
}
|
||||
|
||||
impl clean::Path {
|
||||
crate fn print<'b, 'a: 'b, 'tcx: 'a>(
|
||||
pub(crate) fn print<'b, 'a: 'b, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'b + Captures<'tcx> {
|
||||
@ -1049,7 +1052,7 @@ impl clean::Path {
|
||||
}
|
||||
|
||||
impl clean::Impl {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
use_absolute: bool,
|
||||
cx: &'a Context<'tcx>,
|
||||
@ -1083,7 +1086,7 @@ impl clean::Impl {
|
||||
}
|
||||
|
||||
impl clean::Arguments {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1107,7 +1110,7 @@ impl clean::Arguments {
|
||||
}
|
||||
|
||||
impl clean::FnRetTy {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1142,7 +1145,7 @@ impl clean::BareFunctionDecl {
|
||||
}
|
||||
|
||||
impl clean::FnDecl {
|
||||
crate fn print<'b, 'a: 'b, 'tcx: 'a>(
|
||||
pub(crate) fn print<'b, 'a: 'b, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'b + Captures<'tcx> {
|
||||
@ -1174,7 +1177,7 @@ impl clean::FnDecl {
|
||||
/// * `indent`: The number of spaces to indent each successive line with, if line-wrapping is
|
||||
/// necessary.
|
||||
/// * `asyncness`: Whether the function is async or not.
|
||||
crate fn full_print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn full_print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
header_len: usize,
|
||||
indent: usize,
|
||||
@ -1291,7 +1294,7 @@ impl clean::FnDecl {
|
||||
}
|
||||
|
||||
impl clean::Visibility {
|
||||
crate fn print_with_space<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print_with_space<'a, 'tcx: 'a>(
|
||||
self,
|
||||
item_did: ItemId,
|
||||
cx: &'a Context<'tcx>,
|
||||
@ -1339,7 +1342,7 @@ impl clean::Visibility {
|
||||
/// This function is the same as print_with_space, except that it renders no links.
|
||||
/// It's used for macros' rendered source view, which is syntax highlighted and cannot have
|
||||
/// any HTML in it.
|
||||
crate fn to_src_with_space<'a, 'tcx: 'a>(
|
||||
pub(crate) fn to_src_with_space<'a, 'tcx: 'a>(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
item_did: DefId,
|
||||
@ -1374,7 +1377,7 @@ impl clean::Visibility {
|
||||
}
|
||||
}
|
||||
|
||||
crate trait PrintWithSpace {
|
||||
pub(crate) trait PrintWithSpace {
|
||||
fn print_with_space(&self) -> &str;
|
||||
}
|
||||
|
||||
@ -1405,7 +1408,10 @@ impl PrintWithSpace for hir::Mutability {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn print_constness_with_space(c: &hir::Constness, s: Option<ConstStability>) -> &'static str {
|
||||
pub(crate) fn print_constness_with_space(
|
||||
c: &hir::Constness,
|
||||
s: Option<ConstStability>,
|
||||
) -> &'static str {
|
||||
match (c, s) {
|
||||
// const stable or when feature(staged_api) is not set
|
||||
(
|
||||
@ -1419,7 +1425,7 @@ crate fn print_constness_with_space(c: &hir::Constness, s: Option<ConstStability
|
||||
}
|
||||
|
||||
impl clean::Import {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1443,7 +1449,7 @@ impl clean::Import {
|
||||
}
|
||||
|
||||
impl clean::ImportSource {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1466,7 +1472,7 @@ impl clean::ImportSource {
|
||||
}
|
||||
|
||||
impl clean::TypeBinding {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1500,7 +1506,7 @@ impl clean::TypeBinding {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn print_abi_with_space(abi: Abi) -> impl fmt::Display {
|
||||
pub(crate) fn print_abi_with_space(abi: Abi) -> impl fmt::Display {
|
||||
display_fn(move |f| {
|
||||
let quot = if f.alternate() { "\"" } else { """ };
|
||||
match abi {
|
||||
@ -1510,12 +1516,12 @@ crate fn print_abi_with_space(abi: Abi) -> impl fmt::Display {
|
||||
})
|
||||
}
|
||||
|
||||
crate fn print_default_space<'a>(v: bool) -> &'a str {
|
||||
pub(crate) fn print_default_space<'a>(v: bool) -> &'a str {
|
||||
if v { "default " } else { "" }
|
||||
}
|
||||
|
||||
impl clean::GenericArg {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1529,7 +1535,7 @@ impl clean::GenericArg {
|
||||
}
|
||||
|
||||
impl clean::types::Term {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
pub(crate) fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
@ -1540,7 +1546,9 @@ impl clean::types::Term {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn display_fn(f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
|
||||
pub(crate) fn display_fn(
|
||||
f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result,
|
||||
) -> impl fmt::Display {
|
||||
struct WithFormatter<F>(Cell<Option<F>>);
|
||||
|
||||
impl<F> fmt::Display for WithFormatter<F>
|
||||
|
@ -22,21 +22,21 @@ use super::format::{self, Buffer};
|
||||
use super::render::LinkFromSrc;
|
||||
|
||||
/// This type is needed in case we want to render links on items to allow to go to their definition.
|
||||
crate struct ContextInfo<'a, 'b, 'c> {
|
||||
crate context: &'a Context<'b>,
|
||||
pub(crate) struct ContextInfo<'a, 'b, 'c> {
|
||||
pub(crate) context: &'a Context<'b>,
|
||||
/// This span contains the current file we're going through.
|
||||
crate file_span: Span,
|
||||
pub(crate) file_span: Span,
|
||||
/// This field is used to know "how far" from the top of the directory we are to link to either
|
||||
/// documentation pages or other source pages.
|
||||
crate root_path: &'c str,
|
||||
pub(crate) root_path: &'c str,
|
||||
}
|
||||
|
||||
/// Decorations are represented as a map from CSS class to vector of character ranges.
|
||||
/// Each range will be wrapped in a span with that class.
|
||||
crate struct DecorationInfo(crate FxHashMap<&'static str, Vec<(u32, u32)>>);
|
||||
pub(crate) struct DecorationInfo(pub(crate) FxHashMap<&'static str, Vec<(u32, u32)>>);
|
||||
|
||||
/// Highlights `src`, returning the HTML output.
|
||||
crate fn render_with_highlighting(
|
||||
pub(crate) fn render_with_highlighting(
|
||||
src: &str,
|
||||
out: &mut Buffer,
|
||||
class: Option<&str>,
|
||||
|
@ -10,33 +10,33 @@ use crate::html::render::{ensure_trailing_slash, StylePath};
|
||||
use askama::Template;
|
||||
|
||||
#[derive(Clone)]
|
||||
crate struct Layout {
|
||||
crate logo: String,
|
||||
crate favicon: String,
|
||||
crate external_html: ExternalHtml,
|
||||
crate default_settings: FxHashMap<String, String>,
|
||||
crate krate: String,
|
||||
pub(crate) struct Layout {
|
||||
pub(crate) logo: String,
|
||||
pub(crate) favicon: String,
|
||||
pub(crate) external_html: ExternalHtml,
|
||||
pub(crate) default_settings: FxHashMap<String, String>,
|
||||
pub(crate) krate: String,
|
||||
/// The given user css file which allow to customize the generated
|
||||
/// documentation theme.
|
||||
crate css_file_extension: Option<PathBuf>,
|
||||
pub(crate) css_file_extension: Option<PathBuf>,
|
||||
/// If true, then scrape-examples.js will be included in the output HTML file
|
||||
crate scrape_examples_extension: bool,
|
||||
pub(crate) scrape_examples_extension: bool,
|
||||
}
|
||||
|
||||
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(crate) struct Page<'a> {
|
||||
pub(crate) title: &'a str,
|
||||
pub(crate) css_class: &'a str,
|
||||
pub(crate) root_path: &'a str,
|
||||
pub(crate) static_root_path: Option<&'a str>,
|
||||
pub(crate) description: &'a str,
|
||||
pub(crate) keywords: &'a str,
|
||||
pub(crate) resource_suffix: &'a str,
|
||||
pub(crate) extra_scripts: &'a [&'a str],
|
||||
pub(crate) static_extra_scripts: &'a [&'a str],
|
||||
}
|
||||
|
||||
impl<'a> Page<'a> {
|
||||
crate fn get_static_root_path(&self) -> &str {
|
||||
pub(crate) fn get_static_root_path(&self) -> &str {
|
||||
self.static_root_path.unwrap_or(self.root_path)
|
||||
}
|
||||
}
|
||||
@ -51,10 +51,10 @@ struct PageLayout<'a> {
|
||||
sidebar: String,
|
||||
content: String,
|
||||
krate_with_trailing_slash: String,
|
||||
crate rustdoc_version: &'a str,
|
||||
pub(crate) rustdoc_version: &'a str,
|
||||
}
|
||||
|
||||
crate fn render<T: Print, S: Print>(
|
||||
pub(crate) fn render<T: Print, S: Print>(
|
||||
layout: &Layout,
|
||||
page: &Page<'_>,
|
||||
sidebar: S,
|
||||
@ -86,7 +86,7 @@ crate fn render<T: Print, S: Print>(
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
crate fn redirect(url: &str) -> String {
|
||||
pub(crate) fn redirect(url: &str) -> String {
|
||||
// <script> triggers a redirect before refresh, so this is fine.
|
||||
format!(
|
||||
r##"<!DOCTYPE html>
|
||||
|
@ -104,23 +104,23 @@ pub struct Markdown<'a> {
|
||||
pub heading_offset: HeadingOffset,
|
||||
}
|
||||
/// A tuple struct like `Markdown` that renders the markdown with a table of contents.
|
||||
crate struct MarkdownWithToc<'a>(
|
||||
crate &'a str,
|
||||
crate &'a mut IdMap,
|
||||
crate ErrorCodes,
|
||||
crate Edition,
|
||||
crate &'a Option<Playground>,
|
||||
pub(crate) struct MarkdownWithToc<'a>(
|
||||
pub(crate) &'a str,
|
||||
pub(crate) &'a mut IdMap,
|
||||
pub(crate) ErrorCodes,
|
||||
pub(crate) Edition,
|
||||
pub(crate) &'a Option<Playground>,
|
||||
);
|
||||
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags.
|
||||
crate struct MarkdownHtml<'a>(
|
||||
crate &'a str,
|
||||
crate &'a mut IdMap,
|
||||
crate ErrorCodes,
|
||||
crate Edition,
|
||||
crate &'a Option<Playground>,
|
||||
pub(crate) struct MarkdownHtml<'a>(
|
||||
pub(crate) &'a str,
|
||||
pub(crate) &'a mut IdMap,
|
||||
pub(crate) ErrorCodes,
|
||||
pub(crate) Edition,
|
||||
pub(crate) &'a Option<Playground>,
|
||||
);
|
||||
/// A tuple struct like `Markdown` that renders only the first paragraph.
|
||||
crate struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
|
||||
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum ErrorCodes {
|
||||
@ -129,14 +129,14 @@ pub enum ErrorCodes {
|
||||
}
|
||||
|
||||
impl ErrorCodes {
|
||||
crate fn from(b: bool) -> Self {
|
||||
pub(crate) fn from(b: bool) -> Self {
|
||||
match b {
|
||||
true => ErrorCodes::Yes,
|
||||
false => ErrorCodes::No,
|
||||
}
|
||||
}
|
||||
|
||||
crate fn as_bool(self) -> bool {
|
||||
pub(crate) fn as_bool(self) -> bool {
|
||||
match self {
|
||||
ErrorCodes::Yes => true,
|
||||
ErrorCodes::No => false,
|
||||
@ -716,7 +716,7 @@ impl<'a, I: Iterator<Item = SpannedEvent<'a>>> Iterator for Footnotes<'a, I> {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn find_testable_code<T: doctest::Tester>(
|
||||
pub(crate) fn find_testable_code<T: doctest::Tester>(
|
||||
doc: &str,
|
||||
tests: &mut T,
|
||||
error_codes: ErrorCodes,
|
||||
@ -788,7 +788,7 @@ crate fn find_testable_code<T: doctest::Tester>(
|
||||
}
|
||||
}
|
||||
|
||||
crate struct ExtraInfo<'tcx> {
|
||||
pub(crate) struct ExtraInfo<'tcx> {
|
||||
id: ExtraInfoId,
|
||||
sp: Span,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
@ -800,11 +800,11 @@ enum ExtraInfoId {
|
||||
}
|
||||
|
||||
impl<'tcx> ExtraInfo<'tcx> {
|
||||
crate fn new(tcx: TyCtxt<'tcx>, hir_id: HirId, sp: Span) -> ExtraInfo<'tcx> {
|
||||
pub(crate) fn new(tcx: TyCtxt<'tcx>, hir_id: HirId, sp: Span) -> ExtraInfo<'tcx> {
|
||||
ExtraInfo { id: ExtraInfoId::Hir(hir_id), sp, tcx }
|
||||
}
|
||||
|
||||
crate fn new_did(tcx: TyCtxt<'tcx>, did: DefId, sp: Span) -> ExtraInfo<'tcx> {
|
||||
pub(crate) fn new_did(tcx: TyCtxt<'tcx>, did: DefId, sp: Span) -> ExtraInfo<'tcx> {
|
||||
ExtraInfo { id: ExtraInfoId::Def(did), sp, tcx }
|
||||
}
|
||||
|
||||
@ -835,20 +835,20 @@ impl<'tcx> ExtraInfo<'tcx> {
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug)]
|
||||
crate struct LangString {
|
||||
pub(crate) struct LangString {
|
||||
original: String,
|
||||
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 edition: Option<Edition>,
|
||||
pub(crate) should_panic: bool,
|
||||
pub(crate) no_run: bool,
|
||||
pub(crate) ignore: Ignore,
|
||||
pub(crate) rust: bool,
|
||||
pub(crate) test_harness: bool,
|
||||
pub(crate) compile_fail: bool,
|
||||
pub(crate) error_codes: Vec<String>,
|
||||
pub(crate) edition: Option<Edition>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug)]
|
||||
crate enum Ignore {
|
||||
pub(crate) enum Ignore {
|
||||
All,
|
||||
None,
|
||||
Some(Vec<String>),
|
||||
@ -1058,7 +1058,7 @@ impl Markdown<'_> {
|
||||
}
|
||||
|
||||
impl MarkdownWithToc<'_> {
|
||||
crate fn into_string(self) -> String {
|
||||
pub(crate) fn into_string(self) -> String {
|
||||
let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;
|
||||
|
||||
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();
|
||||
@ -1080,7 +1080,7 @@ impl MarkdownWithToc<'_> {
|
||||
}
|
||||
|
||||
impl MarkdownHtml<'_> {
|
||||
crate fn into_string(self) -> String {
|
||||
pub(crate) fn into_string(self) -> String {
|
||||
let MarkdownHtml(md, mut ids, codes, edition, playground) = self;
|
||||
|
||||
// This is actually common enough to special-case
|
||||
@ -1108,7 +1108,7 @@ impl MarkdownHtml<'_> {
|
||||
}
|
||||
|
||||
impl MarkdownSummaryLine<'_> {
|
||||
crate fn into_string(self) -> String {
|
||||
pub(crate) fn into_string(self) -> String {
|
||||
let MarkdownSummaryLine(md, links) = self;
|
||||
// This is actually common enough to special-case
|
||||
if md.is_empty() {
|
||||
@ -1207,7 +1207,7 @@ fn markdown_summary_with_limit(
|
||||
/// Will shorten to 59 or 60 characters, including an ellipsis (…) if it was shortened.
|
||||
///
|
||||
/// See [`markdown_summary_with_limit`] for details about what is rendered and what is not.
|
||||
crate fn short_markdown_summary(markdown: &str, link_names: &[RenderedLink]) -> String {
|
||||
pub(crate) fn short_markdown_summary(markdown: &str, link_names: &[RenderedLink]) -> String {
|
||||
let (mut s, was_shortened) = markdown_summary_with_limit(markdown, link_names, 59);
|
||||
|
||||
if was_shortened {
|
||||
@ -1223,7 +1223,7 @@ crate fn short_markdown_summary(markdown: &str, link_names: &[RenderedLink]) ->
|
||||
/// - Headings, links, and formatting are stripped.
|
||||
/// - Inline code is rendered as-is, surrounded by backticks.
|
||||
/// - HTML and code blocks are ignored.
|
||||
crate fn plain_text_summary(md: &str) -> String {
|
||||
pub(crate) fn plain_text_summary(md: &str) -> String {
|
||||
if md.is_empty() {
|
||||
return String::new();
|
||||
}
|
||||
@ -1250,13 +1250,16 @@ crate fn plain_text_summary(md: &str) -> String {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
crate struct MarkdownLink {
|
||||
pub(crate) struct MarkdownLink {
|
||||
pub kind: LinkType,
|
||||
pub link: String,
|
||||
pub range: Range<usize>,
|
||||
}
|
||||
|
||||
crate fn markdown_links<R>(md: &str, filter_map: impl Fn(MarkdownLink) -> Option<R>) -> Vec<R> {
|
||||
pub(crate) fn markdown_links<R>(
|
||||
md: &str,
|
||||
filter_map: impl Fn(MarkdownLink) -> Option<R>,
|
||||
) -> Vec<R> {
|
||||
if md.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
@ -1337,19 +1340,19 @@ crate fn markdown_links<R>(md: &str, filter_map: impl Fn(MarkdownLink) -> Option
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
crate struct RustCodeBlock {
|
||||
pub(crate) struct RustCodeBlock {
|
||||
/// The range in the markdown that the code block occupies. Note that this includes the fences
|
||||
/// for fenced code blocks.
|
||||
crate range: Range<usize>,
|
||||
pub(crate) range: Range<usize>,
|
||||
/// The range in the markdown that the code within the code block occupies.
|
||||
crate code: Range<usize>,
|
||||
crate is_fenced: bool,
|
||||
crate lang_string: LangString,
|
||||
pub(crate) code: Range<usize>,
|
||||
pub(crate) is_fenced: bool,
|
||||
pub(crate) lang_string: LangString,
|
||||
}
|
||||
|
||||
/// Returns a range of bytes for each code block in the markdown that is tagged as `rust` or
|
||||
/// untagged (and assumed to be rust).
|
||||
crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeBlock> {
|
||||
pub(crate) fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeBlock> {
|
||||
let mut code_blocks = vec![];
|
||||
|
||||
if md.is_empty() {
|
||||
@ -1492,7 +1495,7 @@ impl IdMap {
|
||||
IdMap { map: DEFAULT_ID_MAP.clone() }
|
||||
}
|
||||
|
||||
crate fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
|
||||
pub(crate) fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
|
||||
let id = match self.map.get_mut(candidate.as_ref()) {
|
||||
None => candidate.to_string(),
|
||||
Some(a) => {
|
||||
|
@ -1,14 +1,14 @@
|
||||
crate mod escape;
|
||||
crate mod format;
|
||||
crate mod highlight;
|
||||
crate mod layout;
|
||||
pub(crate) mod escape;
|
||||
pub(crate) mod format;
|
||||
pub(crate) mod highlight;
|
||||
pub(crate) mod layout;
|
||||
mod length_limit;
|
||||
// used by the error-index generator, so it needs to be public
|
||||
pub mod markdown;
|
||||
crate mod render;
|
||||
crate mod sources;
|
||||
crate mod static_files;
|
||||
crate mod toc;
|
||||
pub(crate) mod render;
|
||||
pub(crate) mod sources;
|
||||
pub(crate) mod static_files;
|
||||
pub(crate) mod toc;
|
||||
mod url_parts_builder;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -42,13 +42,13 @@ use crate::try_err;
|
||||
/// It is intended that this context is a lightweight object which can be fairly
|
||||
/// easily cloned because it is cloned per work-job (about once per item in the
|
||||
/// rustdoc tree).
|
||||
crate struct Context<'tcx> {
|
||||
pub(crate) struct Context<'tcx> {
|
||||
/// Current hierarchy of components leading down to what's currently being
|
||||
/// rendered
|
||||
pub(crate) current: Vec<Symbol>,
|
||||
/// The current destination folder of where HTML artifacts should be placed.
|
||||
/// This changes as the context descends into the module hierarchy.
|
||||
crate dst: PathBuf,
|
||||
pub(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.
|
||||
@ -63,11 +63,11 @@ crate struct Context<'tcx> {
|
||||
/// Issue for improving the situation: [#82381][]
|
||||
///
|
||||
/// [#82381]: https://github.com/rust-lang/rust/issues/82381
|
||||
crate shared: Rc<SharedContext<'tcx>>,
|
||||
pub(crate) shared: Rc<SharedContext<'tcx>>,
|
||||
/// This flag indicates whether source links should be generated or not. If
|
||||
/// the source files are present in the html rendering, then this will be
|
||||
/// `true`.
|
||||
crate include_sources: bool,
|
||||
pub(crate) include_sources: bool,
|
||||
}
|
||||
|
||||
// `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
|
||||
@ -75,16 +75,16 @@ crate struct Context<'tcx> {
|
||||
rustc_data_structures::static_assert_size!(Context<'_>, 144);
|
||||
|
||||
/// Shared mutable state used in [`Context`] and elsewhere.
|
||||
crate struct SharedContext<'tcx> {
|
||||
crate tcx: TyCtxt<'tcx>,
|
||||
pub(crate) struct SharedContext<'tcx> {
|
||||
pub(crate) tcx: TyCtxt<'tcx>,
|
||||
/// The path to the crate root source minus the file name.
|
||||
/// Used for simplifying paths to the highlighted source code files.
|
||||
crate src_root: PathBuf,
|
||||
pub(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).
|
||||
crate layout: layout::Layout,
|
||||
pub(crate) layout: layout::Layout,
|
||||
/// The local file sources we've emitted and their respective url-paths.
|
||||
crate local_sources: FxHashMap<PathBuf, String>,
|
||||
pub(crate) local_sources: FxHashMap<PathBuf, String>,
|
||||
/// Show the memory layout of types in the docs.
|
||||
pub(super) show_type_layout: bool,
|
||||
/// The base-URL of the issue tracker for when an item has been tagged with
|
||||
@ -97,15 +97,15 @@ crate struct SharedContext<'tcx> {
|
||||
/// should be ordered alphabetically or in order of appearance (in the source code).
|
||||
pub(super) sort_modules_alphabetically: bool,
|
||||
/// Additional CSS files to be added to the generated docs.
|
||||
crate style_files: Vec<StylePath>,
|
||||
pub(crate) style_files: Vec<StylePath>,
|
||||
/// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes
|
||||
/// "light-v2.css").
|
||||
crate resource_suffix: String,
|
||||
pub(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.
|
||||
crate static_root_path: Option<String>,
|
||||
pub(crate) static_root_path: Option<String>,
|
||||
/// The fs handle we are working with.
|
||||
crate fs: DocFS,
|
||||
pub(crate) fs: DocFS,
|
||||
pub(super) codes: ErrorCodes,
|
||||
pub(super) playground: Option<markdown::Playground>,
|
||||
all: RefCell<AllTypes>,
|
||||
@ -119,15 +119,15 @@ crate struct SharedContext<'tcx> {
|
||||
|
||||
/// Correspondance map used to link types used in the source code pages to allow to click on
|
||||
/// links to jump to the type's definition.
|
||||
crate span_correspondance_map: FxHashMap<rustc_span::Span, LinkFromSrc>,
|
||||
pub(crate) span_correspondance_map: FxHashMap<rustc_span::Span, LinkFromSrc>,
|
||||
/// The [`Cache`] used during rendering.
|
||||
crate cache: Cache,
|
||||
pub(crate) cache: Cache,
|
||||
|
||||
crate call_locations: AllCallLocations,
|
||||
pub(crate) call_locations: AllCallLocations,
|
||||
}
|
||||
|
||||
impl SharedContext<'_> {
|
||||
crate fn ensure_dir(&self, dst: &Path) -> Result<(), Error> {
|
||||
pub(crate) fn ensure_dir(&self, dst: &Path) -> Result<(), Error> {
|
||||
let mut dirs = self.created_dirs.borrow_mut();
|
||||
if !dirs.contains(dst) {
|
||||
try_err!(self.fs.create_dir_all(dst), dst);
|
||||
@ -137,7 +137,7 @@ impl SharedContext<'_> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
crate fn edition(&self) -> Edition {
|
||||
pub(crate) fn edition(&self) -> Edition {
|
||||
self.tcx.sess.edition()
|
||||
}
|
||||
}
|
||||
@ -301,7 +301,7 @@ impl<'tcx> Context<'tcx> {
|
||||
self.href_from_span(item.span(self.tcx()), true)
|
||||
}
|
||||
|
||||
crate fn href_from_span(&self, span: clean::Span, with_lines: bool) -> Option<String> {
|
||||
pub(crate) fn href_from_span(&self, span: clean::Span, with_lines: bool) -> Option<String> {
|
||||
if span.is_dummy() {
|
||||
return None;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
//! These threads are not parallelized (they haven't been a bottleneck yet), and
|
||||
//! both occur before the crate is rendered.
|
||||
|
||||
crate mod search_index;
|
||||
pub(crate) mod search_index;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@ -33,8 +33,8 @@ mod print_item;
|
||||
mod span_map;
|
||||
mod write_shared;
|
||||
|
||||
crate use self::context::*;
|
||||
crate use self::span_map::{collect_spans_and_sources, LinkFromSrc};
|
||||
pub(crate) use self::context::*;
|
||||
pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc};
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::default::Default;
|
||||
@ -81,9 +81,9 @@ use crate::try_none;
|
||||
use crate::DOC_RUST_LANG_ORG_CHANNEL;
|
||||
|
||||
/// A pair of name and its optional document.
|
||||
crate type NameDoc = (String, Option<String>);
|
||||
pub(crate) type NameDoc = (String, Option<String>);
|
||||
|
||||
crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
|
||||
pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
|
||||
crate::html::format::display_fn(move |f| {
|
||||
if !v.ends_with('/') && !v.is_empty() { write!(f, "{}/", v) } else { f.write_str(v) }
|
||||
})
|
||||
@ -95,27 +95,27 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
|
||||
/// 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)]
|
||||
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>,
|
||||
crate aliases: Box<[Symbol]>,
|
||||
pub(crate) struct IndexItem {
|
||||
pub(crate) ty: ItemType,
|
||||
pub(crate) name: String,
|
||||
pub(crate) path: String,
|
||||
pub(crate) desc: String,
|
||||
pub(crate) parent: Option<DefId>,
|
||||
pub(crate) parent_idx: Option<usize>,
|
||||
pub(crate) search_type: Option<IndexItemFunctionType>,
|
||||
pub(crate) aliases: Box<[Symbol]>,
|
||||
}
|
||||
|
||||
/// A type used for the search index.
|
||||
#[derive(Debug)]
|
||||
crate struct RenderType {
|
||||
pub(crate) struct RenderType {
|
||||
name: Option<String>,
|
||||
generics: Option<Vec<TypeWithKind>>,
|
||||
}
|
||||
|
||||
/// Full type of functions/methods in the search index.
|
||||
#[derive(Debug)]
|
||||
crate struct IndexItemFunctionType {
|
||||
pub(crate) struct IndexItemFunctionType {
|
||||
inputs: Vec<TypeWithKind>,
|
||||
output: Vec<TypeWithKind>,
|
||||
}
|
||||
@ -143,7 +143,7 @@ impl Serialize for IndexItemFunctionType {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
crate struct TypeWithKind {
|
||||
pub(crate) struct TypeWithKind {
|
||||
ty: RenderType,
|
||||
kind: ItemType,
|
||||
}
|
||||
@ -170,13 +170,13 @@ impl Serialize for TypeWithKind {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
crate struct StylePath {
|
||||
pub(crate) struct StylePath {
|
||||
/// The path to the theme
|
||||
crate path: PathBuf,
|
||||
pub(crate) path: PathBuf,
|
||||
}
|
||||
|
||||
impl StylePath {
|
||||
crate fn basename(&self) -> Result<String, Error> {
|
||||
pub(crate) fn basename(&self) -> Result<String, Error> {
|
||||
Ok(try_none!(try_none!(self.path.file_stem(), &self.path).to_str(), &self.path).to_string())
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ impl ItemEntry {
|
||||
}
|
||||
|
||||
impl ItemEntry {
|
||||
crate fn print(&self) -> impl fmt::Display + '_ {
|
||||
pub(crate) fn print(&self) -> impl fmt::Display + '_ {
|
||||
crate::html::format::display_fn(move |f| {
|
||||
write!(f, "<a href=\"{}\">{}</a>", self.url, Escape(&self.name))
|
||||
})
|
||||
@ -2580,7 +2580,7 @@ fn sidebar_foreign_type(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) {
|
||||
}
|
||||
}
|
||||
|
||||
crate const BASIC_KEYWORDS: &str = "rust, rustlang, rust-lang";
|
||||
pub(crate) const BASIC_KEYWORDS: &str = "rust, rustlang, rust-lang";
|
||||
|
||||
/// Returns a list of all paths used in the type.
|
||||
/// This is used to help deduplicate imported impls
|
||||
|
@ -246,14 +246,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
|
||||
// This call is to remove re-export duplicates in cases such as:
|
||||
//
|
||||
// ```
|
||||
// crate mod foo {
|
||||
// crate mod bar {
|
||||
// crate trait Double { fn foo(); }
|
||||
// pub(crate) mod foo {
|
||||
// pub(crate) mod bar {
|
||||
// pub(crate) trait Double { fn foo(); }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// crate use foo::bar::*;
|
||||
// crate use foo::*;
|
||||
// pub(crate) use foo::bar::*;
|
||||
// pub(crate) use foo::*;
|
||||
// ```
|
||||
//
|
||||
// `Double` will appear twice in the generated docs.
|
||||
@ -1473,7 +1473,7 @@ fn item_keyword(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
|
||||
}
|
||||
|
||||
/// Compare two strings treating multi-digit numbers as single units (i.e. natural sort order).
|
||||
crate fn compare_names(mut lhs: &str, mut rhs: &str) -> Ordering {
|
||||
pub(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());
|
||||
|
@ -15,7 +15,11 @@ use crate::html::markdown::short_markdown_summary;
|
||||
use crate::html::render::{IndexItem, IndexItemFunctionType, RenderType, TypeWithKind};
|
||||
|
||||
/// Builds the search index from the collected metadata
|
||||
crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<'tcx>) -> String {
|
||||
pub(crate) fn build_index<'tcx>(
|
||||
krate: &clean::Crate,
|
||||
cache: &mut Cache,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> String {
|
||||
let mut defid_to_pathid = FxHashMap::default();
|
||||
let mut crate_paths = vec![];
|
||||
|
||||
@ -185,7 +189,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
|
||||
)
|
||||
}
|
||||
|
||||
crate fn get_function_type_for_search<'tcx>(
|
||||
pub(crate) fn get_function_type_for_search<'tcx>(
|
||||
item: &clean::Item,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cache: &Cache,
|
||||
|
@ -20,7 +20,7 @@ use std::path::{Path, PathBuf};
|
||||
/// Otherwise, we store the definition `DefId` and will generate a link to the documentation page
|
||||
/// instead of the source code directly.
|
||||
#[derive(Debug)]
|
||||
crate enum LinkFromSrc {
|
||||
pub(crate) enum LinkFromSrc {
|
||||
Local(clean::Span),
|
||||
External(DefId),
|
||||
Primitive(PrimitiveType),
|
||||
@ -36,7 +36,7 @@ crate enum LinkFromSrc {
|
||||
/// Note about the `span` correspondance map: the keys are actually `(lo, hi)` of `span`s. We don't
|
||||
/// need the `span` context later on, only their position, so instead of keep a whole `Span`, we
|
||||
/// only keep the `lo` and `hi`.
|
||||
crate fn collect_spans_and_sources(
|
||||
pub(crate) fn collect_spans_and_sources(
|
||||
tcx: TyCtxt<'_>,
|
||||
krate: &clean::Crate,
|
||||
src_root: &Path,
|
||||
@ -57,8 +57,8 @@ crate fn collect_spans_and_sources(
|
||||
}
|
||||
|
||||
struct SpanMapVisitor<'tcx> {
|
||||
crate tcx: TyCtxt<'tcx>,
|
||||
crate matches: FxHashMap<Span, LinkFromSrc>,
|
||||
pub(crate) tcx: TyCtxt<'tcx>,
|
||||
pub(crate) matches: FxHashMap<Span, LinkFromSrc>,
|
||||
}
|
||||
|
||||
impl<'tcx> SpanMapVisitor<'tcx> {
|
||||
|
@ -16,7 +16,7 @@ use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
crate fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), Error> {
|
||||
pub(crate) fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), Error> {
|
||||
info!("emitting source files");
|
||||
|
||||
let dst = cx.dst.join("src").join(krate.name(cx.tcx()).as_str());
|
||||
@ -27,7 +27,7 @@ crate fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), Error>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
crate fn collect_local_sources<'tcx>(
|
||||
pub(crate) fn collect_local_sources<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
src_root: &Path,
|
||||
krate: &clean::Crate,
|
||||
@ -231,7 +231,7 @@ impl SourceCollector<'_, '_> {
|
||||
/// 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.
|
||||
crate fn clean_path<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F)
|
||||
pub(crate) fn clean_path<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F)
|
||||
where
|
||||
F: FnMut(&OsStr),
|
||||
{
|
||||
@ -253,14 +253,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
crate enum SourceContext {
|
||||
pub(crate) enum SourceContext {
|
||||
Standalone,
|
||||
Embedded { offset: usize },
|
||||
}
|
||||
|
||||
/// Wrapper struct to render the source code of a file. This will do things like
|
||||
/// adding line numbers to the left-hand side.
|
||||
crate fn print_src(
|
||||
pub(crate) fn print_src(
|
||||
buf: &mut Buffer,
|
||||
s: &str,
|
||||
edition: Edition,
|
||||
|
@ -8,131 +8,134 @@
|
||||
//! directly written to a `Write` handle.
|
||||
|
||||
/// The file contents of the main `rustdoc.css` file, responsible for the core layout of the page.
|
||||
crate static RUSTDOC_CSS: &str = include_str!("static/css/rustdoc.css");
|
||||
pub(crate) static RUSTDOC_CSS: &str = include_str!("static/css/rustdoc.css");
|
||||
|
||||
/// The file contents of `settings.css`, responsible for the items on the settings page.
|
||||
crate static SETTINGS_CSS: &str = include_str!("static/css/settings.css");
|
||||
pub(crate) static SETTINGS_CSS: &str = include_str!("static/css/settings.css");
|
||||
|
||||
/// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled.
|
||||
crate static NOSCRIPT_CSS: &str = include_str!("static/css/noscript.css");
|
||||
pub(crate) static NOSCRIPT_CSS: &str = include_str!("static/css/noscript.css");
|
||||
|
||||
/// The file contents of `normalize.css`, included to even out standard elements between browser
|
||||
/// implementations.
|
||||
crate static NORMALIZE_CSS: &str = include_str!("static/css/normalize.css");
|
||||
pub(crate) static NORMALIZE_CSS: &str = include_str!("static/css/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.
|
||||
crate static MAIN_JS: &str = include_str!("static/js/main.js");
|
||||
pub(crate) static MAIN_JS: &str = include_str!("static/js/main.js");
|
||||
|
||||
/// The file contents of `search.js`, which contains the search behavior.
|
||||
crate static SEARCH_JS: &str = include_str!("static/js/search.js");
|
||||
pub(crate) static SEARCH_JS: &str = include_str!("static/js/search.js");
|
||||
|
||||
/// The file contents of `settings.js`, which contains the JavaScript used to handle the settings
|
||||
/// page.
|
||||
crate static SETTINGS_JS: &str = include_str!("static/js/settings.js");
|
||||
pub(crate) static SETTINGS_JS: &str = include_str!("static/js/settings.js");
|
||||
|
||||
/// The file contents of `storage.js`, which contains functionality related to browser Local
|
||||
/// Storage, used to store documentation settings.
|
||||
crate static STORAGE_JS: &str = include_str!("static/js/storage.js");
|
||||
pub(crate) static STORAGE_JS: &str = include_str!("static/js/storage.js");
|
||||
|
||||
/// The file contents of `scraped-examples.js`, which contains functionality related to the
|
||||
/// --scrape-examples flag that inserts automatically-found examples of usages of items.
|
||||
crate static SCRAPE_EXAMPLES_JS: &str = include_str!("static/js/scrape-examples.js");
|
||||
pub(crate) static SCRAPE_EXAMPLES_JS: &str = include_str!("static/js/scrape-examples.js");
|
||||
|
||||
crate static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/scrape-examples-help.md");
|
||||
pub(crate) static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/scrape-examples-help.md");
|
||||
|
||||
/// The file contents of `wheel.svg`, the icon used for the settings button.
|
||||
crate static WHEEL_SVG: &[u8] = include_bytes!("static/images/wheel.svg");
|
||||
pub(crate) static WHEEL_SVG: &[u8] = include_bytes!("static/images/wheel.svg");
|
||||
|
||||
/// The file contents of `clipboard.svg`, the icon used for the "copy path" button.
|
||||
crate static CLIPBOARD_SVG: &[u8] = include_bytes!("static/images/clipboard.svg");
|
||||
pub(crate) static CLIPBOARD_SVG: &[u8] = include_bytes!("static/images/clipboard.svg");
|
||||
|
||||
/// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox.
|
||||
crate static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/images/down-arrow.svg");
|
||||
pub(crate) static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/images/down-arrow.svg");
|
||||
|
||||
/// The file contents of `toggle-minus.svg`, the icon used for opened toggles.
|
||||
crate static TOGGLE_MINUS_PNG: &[u8] = include_bytes!("static/images/toggle-minus.svg");
|
||||
pub(crate) static TOGGLE_MINUS_PNG: &[u8] = include_bytes!("static/images/toggle-minus.svg");
|
||||
|
||||
/// The file contents of `toggle-plus.svg`, the icon used for closed toggles.
|
||||
crate static TOGGLE_PLUS_PNG: &[u8] = include_bytes!("static/images/toggle-plus.svg");
|
||||
pub(crate) static TOGGLE_PLUS_PNG: &[u8] = include_bytes!("static/images/toggle-plus.svg");
|
||||
|
||||
/// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation
|
||||
/// output.
|
||||
crate static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt");
|
||||
pub(crate) static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt");
|
||||
|
||||
/// The contents of `LICENSE-APACHE.txt`, the text of the Apache License, version 2.0.
|
||||
crate static LICENSE_APACHE: &[u8] = include_bytes!("static/LICENSE-APACHE.txt");
|
||||
pub(crate) static LICENSE_APACHE: &[u8] = include_bytes!("static/LICENSE-APACHE.txt");
|
||||
|
||||
/// The contents of `LICENSE-MIT.txt`, the text of the MIT License.
|
||||
crate static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
|
||||
pub(crate) static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
|
||||
|
||||
/// The contents of `rust-logo.svg`, the default icon of the documentation.
|
||||
crate static RUST_LOGO_SVG: &[u8] = include_bytes!("static/images/rust-logo.svg");
|
||||
pub(crate) static RUST_LOGO_SVG: &[u8] = include_bytes!("static/images/rust-logo.svg");
|
||||
|
||||
/// The default documentation favicons (SVG and PNG fallbacks)
|
||||
crate static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/images/favicon.svg");
|
||||
crate static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/images/favicon-16x16.png");
|
||||
crate static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/images/favicon-32x32.png");
|
||||
pub(crate) static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/images/favicon.svg");
|
||||
pub(crate) static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/images/favicon-16x16.png");
|
||||
pub(crate) static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/images/favicon-32x32.png");
|
||||
|
||||
/// The built-in themes given to every documentation site.
|
||||
crate mod themes {
|
||||
pub(crate) mod themes {
|
||||
/// The "light" theme, selected by default when no setting is available. Used as the basis for
|
||||
/// the `--check-theme` functionality.
|
||||
crate static LIGHT: &str = include_str!("static/css/themes/light.css");
|
||||
pub(crate) static LIGHT: &str = include_str!("static/css/themes/light.css");
|
||||
|
||||
/// The "dark" theme.
|
||||
crate static DARK: &str = include_str!("static/css/themes/dark.css");
|
||||
pub(crate) static DARK: &str = include_str!("static/css/themes/dark.css");
|
||||
|
||||
/// The "ayu" theme.
|
||||
crate static AYU: &str = include_str!("static/css/themes/ayu.css");
|
||||
pub(crate) static AYU: &str = include_str!("static/css/themes/ayu.css");
|
||||
}
|
||||
|
||||
/// Files related to the Fira Sans font.
|
||||
crate mod fira_sans {
|
||||
pub(crate) mod fira_sans {
|
||||
/// The file `FiraSans-Regular.woff2`, the Regular variant of the Fira Sans font in woff2.
|
||||
crate static REGULAR: &[u8] = include_bytes!("static/fonts/FiraSans-Regular.woff2");
|
||||
pub(crate) static REGULAR: &[u8] = include_bytes!("static/fonts/FiraSans-Regular.woff2");
|
||||
|
||||
/// The file `FiraSans-Medium.woff2`, the Medium variant of the Fira Sans font in woff2.
|
||||
crate static MEDIUM: &[u8] = include_bytes!("static/fonts/FiraSans-Medium.woff2");
|
||||
pub(crate) static MEDIUM: &[u8] = include_bytes!("static/fonts/FiraSans-Medium.woff2");
|
||||
|
||||
/// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font.
|
||||
crate static LICENSE: &[u8] = include_bytes!("static/fonts/FiraSans-LICENSE.txt");
|
||||
pub(crate) static LICENSE: &[u8] = include_bytes!("static/fonts/FiraSans-LICENSE.txt");
|
||||
}
|
||||
|
||||
/// Files related to the Source Serif 4 font.
|
||||
crate mod source_serif_4 {
|
||||
pub(crate) mod source_serif_4 {
|
||||
/// The file `SourceSerif4-Regular.ttf.woff2`, the Regular variant of the Source Serif 4 font in
|
||||
/// woff2.
|
||||
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff2");
|
||||
pub(crate) static REGULAR: &[u8] =
|
||||
include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff2");
|
||||
|
||||
/// The file `SourceSerif4-Bold.ttf.woff2`, the Bold variant of the Source Serif 4 font in
|
||||
/// woff2.
|
||||
crate static BOLD: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff2");
|
||||
pub(crate) static BOLD: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff2");
|
||||
|
||||
/// The file `SourceSerif4-It.ttf.woff2`, the Italic variant of the Source Serif 4 font in
|
||||
/// woff2.
|
||||
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceSerif4-It.ttf.woff2");
|
||||
pub(crate) static ITALIC: &[u8] = include_bytes!("static/fonts/SourceSerif4-It.ttf.woff2");
|
||||
|
||||
/// The file `SourceSerif4-LICENSE.txt`, the license text for the Source Serif 4 font.
|
||||
crate static LICENSE: &[u8] = include_bytes!("static/fonts/SourceSerif4-LICENSE.md");
|
||||
pub(crate) static LICENSE: &[u8] = include_bytes!("static/fonts/SourceSerif4-LICENSE.md");
|
||||
}
|
||||
|
||||
/// Files related to the Source Code Pro font.
|
||||
crate mod source_code_pro {
|
||||
pub(crate) mod source_code_pro {
|
||||
/// The file `SourceCodePro-Regular.ttf.woff2`, the Regular variant of the Source Code Pro font
|
||||
/// in woff2.
|
||||
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff2");
|
||||
pub(crate) static REGULAR: &[u8] =
|
||||
include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff2");
|
||||
|
||||
/// The file `SourceCodePro-Semibold.ttf.woff2`, the Semibold variant of the Source Code Pro
|
||||
/// font in woff2.
|
||||
crate static SEMIBOLD: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff2");
|
||||
pub(crate) static SEMIBOLD: &[u8] =
|
||||
include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff2");
|
||||
|
||||
/// The file `SourceCodePro-It.ttf.woff2`, the Italic variant of the Source Code Pro font in
|
||||
/// woff2.
|
||||
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceCodePro-It.ttf.woff2");
|
||||
pub(crate) static ITALIC: &[u8] = include_bytes!("static/fonts/SourceCodePro-It.ttf.woff2");
|
||||
|
||||
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
|
||||
crate static LICENSE: &[u8] = include_bytes!("static/fonts/SourceCodePro-LICENSE.txt");
|
||||
pub(crate) static LICENSE: &[u8] = include_bytes!("static/fonts/SourceCodePro-LICENSE.txt");
|
||||
}
|
||||
|
||||
/// Files related to the Nanum Barun Gothic font.
|
||||
@ -150,16 +153,16 @@ crate mod source_code_pro {
|
||||
/// --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
|
||||
/// --output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2
|
||||
/// ```
|
||||
crate mod nanum_barun_gothic {
|
||||
pub(crate) mod nanum_barun_gothic {
|
||||
/// The file `NanumBarunGothic.ttf.woff2`, the Regular variant of the Nanum Barun Gothic font.
|
||||
crate static REGULAR: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff2");
|
||||
pub(crate) static REGULAR: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff2");
|
||||
|
||||
/// The file `NanumBarunGothic-LICENSE.txt`, the license text of the Nanum Barun Gothic font.
|
||||
crate static LICENSE: &[u8] = include_bytes!("static/fonts/NanumBarunGothic-LICENSE.txt");
|
||||
pub(crate) static LICENSE: &[u8] = include_bytes!("static/fonts/NanumBarunGothic-LICENSE.txt");
|
||||
}
|
||||
|
||||
/// Files related to the sidebar in rustdoc sources.
|
||||
crate mod sidebar {
|
||||
pub(crate) mod sidebar {
|
||||
/// File script to handle sidebar.
|
||||
crate static SOURCE_SCRIPT: &str = include_str!("static/js/source-script.js");
|
||||
pub(crate) static SOURCE_SCRIPT: &str = include_str!("static/js/source-script.js");
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/// A (recursive) table of contents
|
||||
#[derive(Debug, PartialEq)]
|
||||
crate struct Toc {
|
||||
pub(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)]
|
||||
crate struct TocEntry {
|
||||
pub(crate) struct TocEntry {
|
||||
level: u32,
|
||||
sec_number: String,
|
||||
name: String,
|
||||
@ -36,7 +36,7 @@ crate struct TocEntry {
|
||||
|
||||
/// Progressive construction of a table of contents.
|
||||
#[derive(PartialEq)]
|
||||
crate struct TocBuilder {
|
||||
pub(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 @@ crate struct TocBuilder {
|
||||
}
|
||||
|
||||
impl TocBuilder {
|
||||
crate fn new() -> TocBuilder {
|
||||
pub(crate) fn new() -> TocBuilder {
|
||||
TocBuilder { top_level: Toc { entries: Vec::new() }, chain: Vec::new() }
|
||||
}
|
||||
|
||||
/// Converts into a true `Toc` struct.
|
||||
crate fn into_toc(mut self) -> Toc {
|
||||
pub(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.
|
||||
crate fn push(&mut self, level: u32, name: String, id: String) -> &str {
|
||||
pub(crate) fn push(&mut self, level: u32, name: String, id: String) -> &str {
|
||||
assert!(level >= 1);
|
||||
|
||||
// collapse all previous sections into their parents until we
|
||||
@ -177,7 +177,7 @@ impl Toc {
|
||||
}
|
||||
v.push_str("</ul>");
|
||||
}
|
||||
crate fn print(&self) -> String {
|
||||
pub(crate) fn print(&self) -> String {
|
||||
let mut v = String::new();
|
||||
self.print_inner(&mut v);
|
||||
v
|
||||
|
@ -8,14 +8,14 @@ use rustc_span::Symbol;
|
||||
/// This type is a wrapper around the final `String` buffer,
|
||||
/// but its API is like that of a `Vec` of URL components.
|
||||
#[derive(Debug)]
|
||||
crate struct UrlPartsBuilder {
|
||||
pub(crate) struct UrlPartsBuilder {
|
||||
buf: String,
|
||||
}
|
||||
|
||||
impl UrlPartsBuilder {
|
||||
/// Create an empty buffer.
|
||||
#[allow(dead_code)]
|
||||
crate fn new() -> Self {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self { buf: String::new() }
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ impl UrlPartsBuilder {
|
||||
/// builder.push_front("nightly");
|
||||
/// assert_eq!(builder.finish(), "nightly/core/str");
|
||||
/// ```
|
||||
crate fn singleton(part: &str) -> Self {
|
||||
pub(crate) fn singleton(part: &str) -> Self {
|
||||
Self { buf: part.to_owned() }
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ impl UrlPartsBuilder {
|
||||
/// builder.push("struct.Bytes.html");
|
||||
/// assert_eq!(builder.finish(), "core/str/struct.Bytes.html");
|
||||
/// ```
|
||||
crate fn push(&mut self, part: &str) {
|
||||
pub(crate) fn push(&mut self, part: &str) {
|
||||
if !self.buf.is_empty() {
|
||||
self.buf.push('/');
|
||||
}
|
||||
@ -80,7 +80,7 @@ impl UrlPartsBuilder {
|
||||
/// builder.push_fmt(format_args!("{}.{}.html", "struct", "Bytes"));
|
||||
/// assert_eq!(builder.finish(), "core/str/struct.Bytes.html");
|
||||
/// ```
|
||||
crate fn push_fmt(&mut self, args: fmt::Arguments<'_>) {
|
||||
pub(crate) fn push_fmt(&mut self, args: fmt::Arguments<'_>) {
|
||||
if !self.buf.is_empty() {
|
||||
self.buf.push('/');
|
||||
}
|
||||
@ -101,7 +101,7 @@ impl UrlPartsBuilder {
|
||||
/// builder.push("struct.Bytes.html");
|
||||
/// assert_eq!(builder.finish(), "nightly/core/str/struct.Bytes.html");
|
||||
/// ```
|
||||
crate fn push_front(&mut self, part: &str) {
|
||||
pub(crate) fn push_front(&mut self, part: &str) {
|
||||
let is_empty = self.buf.is_empty();
|
||||
self.buf.reserve(part.len() + if !is_empty { 1 } else { 0 });
|
||||
self.buf.insert_str(0, part);
|
||||
@ -111,7 +111,7 @@ impl UrlPartsBuilder {
|
||||
}
|
||||
|
||||
/// Get the final `String` buffer.
|
||||
crate fn finish(self) -> String {
|
||||
pub(crate) fn finish(self) -> String {
|
||||
self.buf
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ const AVG_PART_LENGTH: usize = 8;
|
||||
///
|
||||
/// **Note:** This is only to be used with, e.g., [`String::with_capacity()`];
|
||||
/// the return value is just a rough estimate.
|
||||
crate const fn estimate_item_path_byte_length(segment_count: usize) -> usize {
|
||||
pub(crate) const fn estimate_item_path_byte_length(segment_count: usize) -> usize {
|
||||
AVG_PART_LENGTH * segment_count
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ impl JsonRenderer<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
crate trait FromWithTcx<T> {
|
||||
pub(crate) trait FromWithTcx<T> {
|
||||
fn from_tcx(f: T, tcx: TyCtxt<'_>) -> Self;
|
||||
}
|
||||
|
||||
crate trait IntoWithTcx<T> {
|
||||
pub(crate) trait IntoWithTcx<T> {
|
||||
fn into_tcx(self, tcx: TyCtxt<'_>) -> T;
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecation {
|
||||
pub(crate) fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecation {
|
||||
#[rustfmt::skip]
|
||||
let rustc_attr::Deprecation { since, note, is_since_rustc_version: _, suggestion: _ } = deprecation;
|
||||
Deprecation { since: since.map(|s| s.to_string()), note: note.map(|s| s.to_string()) }
|
||||
@ -173,7 +173,7 @@ impl FromWithTcx<clean::TypeBindingKind> for TypeBindingKind {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_item_id(item_id: ItemId) -> Id {
|
||||
pub(crate) fn from_item_id(item_id: ItemId) -> Id {
|
||||
struct DisplayDefId(DefId);
|
||||
|
||||
impl fmt::Display for DisplayDefId {
|
||||
@ -272,7 +272,7 @@ impl FromWithTcx<clean::Union> for Union {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_ctor_kind(struct_type: CtorKind) -> StructType {
|
||||
pub(crate) fn from_ctor_kind(struct_type: CtorKind) -> StructType {
|
||||
match struct_type {
|
||||
CtorKind::Fictive => StructType::Plain,
|
||||
CtorKind::Fn => StructType::Tuple,
|
||||
@ -280,7 +280,7 @@ crate fn from_ctor_kind(struct_type: CtorKind) -> StructType {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_fn_header(header: &rustc_hir::FnHeader) -> Header {
|
||||
pub(crate) fn from_fn_header(header: &rustc_hir::FnHeader) -> Header {
|
||||
Header {
|
||||
async_: header.is_async(),
|
||||
const_: header.is_const(),
|
||||
@ -390,7 +390,9 @@ impl FromWithTcx<clean::GenericBound> for GenericBound {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_trait_bound_modifier(modifier: rustc_hir::TraitBoundModifier) -> TraitBoundModifier {
|
||||
pub(crate) fn from_trait_bound_modifier(
|
||||
modifier: rustc_hir::TraitBoundModifier,
|
||||
) -> TraitBoundModifier {
|
||||
use rustc_hir::TraitBoundModifier::*;
|
||||
match modifier {
|
||||
None => TraitBoundModifier::None,
|
||||
@ -554,7 +556,7 @@ impl FromWithTcx<clean::Impl> for Impl {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_function(
|
||||
pub(crate) fn from_function(
|
||||
function: clean::Function,
|
||||
header: rustc_hir::FnHeader,
|
||||
tcx: TyCtxt<'_>,
|
||||
@ -567,7 +569,7 @@ crate fn from_function(
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_function_method(
|
||||
pub(crate) fn from_function_method(
|
||||
function: clean::Function,
|
||||
has_body: bool,
|
||||
header: rustc_hir::FnHeader,
|
||||
@ -658,7 +660,7 @@ impl FromWithTcx<clean::ProcMacro> for ProcMacro {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn from_macro_kind(kind: rustc_span::hygiene::MacroKind) -> MacroKind {
|
||||
pub(crate) fn from_macro_kind(kind: rustc_span::hygiene::MacroKind) -> MacroKind {
|
||||
use rustc_span::hygiene::MacroKind::*;
|
||||
match kind {
|
||||
Bang => MacroKind::Bang,
|
||||
|
@ -29,7 +29,7 @@ use crate::json::conversions::{from_item_id, IntoWithTcx};
|
||||
use crate::{clean, try_err};
|
||||
|
||||
#[derive(Clone)]
|
||||
crate struct JsonRenderer<'tcx> {
|
||||
pub(crate) struct JsonRenderer<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
/// A mapping of IDs that contains all local items for this crate which gets output as a top
|
||||
/// level field of the JSON blob.
|
||||
|
@ -13,7 +13,6 @@
|
||||
#![feature(let_else)]
|
||||
#![feature(nll)]
|
||||
#![feature(test)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(never_type)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(type_ascription)]
|
||||
@ -121,7 +120,7 @@ mod formats;
|
||||
// used by the error-index generator, so it needs to be public
|
||||
pub mod html;
|
||||
mod json;
|
||||
crate mod lint;
|
||||
pub(crate) mod lint;
|
||||
mod markdown;
|
||||
mod passes;
|
||||
mod scrape_examples;
|
||||
|
@ -169,7 +169,7 @@ declare_rustdoc_lint! {
|
||||
"codeblock could not be parsed as valid Rust or is empty"
|
||||
}
|
||||
|
||||
crate static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
|
||||
pub(crate) static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
|
||||
vec![
|
||||
BROKEN_INTRA_DOC_LINKS,
|
||||
PRIVATE_INTRA_DOC_LINKS,
|
||||
@ -183,7 +183,7 @@ crate static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
|
||||
]
|
||||
});
|
||||
|
||||
crate fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
|
||||
pub(crate) fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
|
||||
lint_store.register_lints(&**RUSTDOC_LINTS);
|
||||
lint_store.register_group(
|
||||
true,
|
||||
|
@ -36,7 +36,7 @@ fn extract_leading_metadata(s: &str) -> (Vec<&str>, &str) {
|
||||
|
||||
/// Render `input` (e.g., "foo.md") into an HTML file in `output`
|
||||
/// (e.g., output = "bar" => "bar/foo.html").
|
||||
crate fn render<P: AsRef<Path>>(
|
||||
pub(crate) fn render<P: AsRef<Path>>(
|
||||
input: P,
|
||||
options: RenderOptions,
|
||||
edition: Edition,
|
||||
@ -127,7 +127,7 @@ crate fn render<P: AsRef<Path>>(
|
||||
}
|
||||
|
||||
/// Runs any tests/code examples in the markdown file `input`.
|
||||
crate fn test(options: Options) -> Result<(), String> {
|
||||
pub(crate) fn test(options: Options) -> Result<(), String> {
|
||||
let input_str = read_to_string(&options.input)
|
||||
.map_err(|err| format!("{}: {}", options.input.display(), err))?;
|
||||
let mut opts = GlobalTestOptions::default();
|
||||
|
@ -12,7 +12,7 @@ use rustc_errors::Applicability;
|
||||
use std::lazy::SyncLazy;
|
||||
use std::mem;
|
||||
|
||||
crate const CHECK_BARE_URLS: Pass = Pass {
|
||||
pub(crate) const CHECK_BARE_URLS: Pass = Pass {
|
||||
name: "check-bare-urls",
|
||||
run: check_bare_urls,
|
||||
description: "detects URLs that are not hyperlinks",
|
||||
@ -54,7 +54,7 @@ impl<'a, 'tcx> BareUrlsLinter<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn check_bare_urls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
pub(crate) fn check_bare_urls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
BareUrlsLinter { cx }.visit_crate(&krate);
|
||||
krate
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops;
|
||||
|
||||
crate const CALCULATE_DOC_COVERAGE: Pass = Pass {
|
||||
pub(crate) const CALCULATE_DOC_COVERAGE: Pass = Pass {
|
||||
name: "calculate-doc-coverage",
|
||||
run: calculate_doc_coverage,
|
||||
description: "counts the number of items with and without documentation",
|
||||
|
@ -14,13 +14,16 @@ use crate::html::markdown::{self, RustCodeBlock};
|
||||
use crate::passes::Pass;
|
||||
use crate::visit::DocVisitor;
|
||||
|
||||
crate const CHECK_CODE_BLOCK_SYNTAX: Pass = Pass {
|
||||
pub(crate) const CHECK_CODE_BLOCK_SYNTAX: Pass = Pass {
|
||||
name: "check-code-block-syntax",
|
||||
run: check_code_block_syntax,
|
||||
description: "validates syntax inside Rust code blocks",
|
||||
};
|
||||
|
||||
crate fn check_code_block_syntax(krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
|
||||
pub(crate) fn check_code_block_syntax(
|
||||
krate: clean::Crate,
|
||||
cx: &mut DocContext<'_>,
|
||||
) -> clean::Crate {
|
||||
SyntaxChecker { cx }.visit_crate(&krate);
|
||||
krate
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use rustc_middle::lint::LintLevelSource;
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
crate const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {
|
||||
pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {
|
||||
name: "check_doc_test_visibility",
|
||||
run: check_doc_test_visibility,
|
||||
description: "run various visibility-related lints on doctests",
|
||||
@ -27,7 +27,7 @@ struct DocTestVisibilityLinter<'a, 'tcx> {
|
||||
cx: &'a mut DocContext<'tcx>,
|
||||
}
|
||||
|
||||
crate fn check_doc_test_visibility(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
pub(crate) fn check_doc_test_visibility(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
let mut coll = DocTestVisibilityLinter { cx };
|
||||
coll.visit_crate(&krate);
|
||||
krate
|
||||
@ -55,7 +55,7 @@ impl crate::doctest::Tester for Tests {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
|
||||
pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
|
||||
if !cx.cache.access_levels.is_public(item.item_id.expect_def_id())
|
||||
|| matches!(
|
||||
*item.kind,
|
||||
@ -106,7 +106,7 @@ crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> boo
|
||||
level != lint::Level::Allow || matches!(source, LintLevelSource::Default)
|
||||
}
|
||||
|
||||
crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
||||
pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
||||
let Some(hir_id) = DocContext::as_local_hir_id(cx.tcx, item.item_id)
|
||||
else {
|
||||
// If non-local, no need to check anything.
|
||||
|
@ -33,9 +33,9 @@ use crate::passes::Pass;
|
||||
use crate::visit::DocVisitor;
|
||||
|
||||
mod early;
|
||||
crate use early::early_resolve_intra_doc_links;
|
||||
pub(crate) use early::early_resolve_intra_doc_links;
|
||||
|
||||
crate const COLLECT_INTRA_DOC_LINKS: Pass = Pass {
|
||||
pub(crate) const COLLECT_INTRA_DOC_LINKS: Pass = Pass {
|
||||
name: "collect-intra-doc-links",
|
||||
run: collect_intra_doc_links,
|
||||
description: "resolves intra-doc links",
|
||||
@ -219,14 +219,14 @@ enum MalformedGenerics {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
||||
crate enum UrlFragment {
|
||||
pub(crate) enum UrlFragment {
|
||||
Item(ItemFragment),
|
||||
UserWritten(String),
|
||||
}
|
||||
|
||||
impl UrlFragment {
|
||||
/// Render the fragment, including the leading `#`.
|
||||
crate fn render(&self, s: &mut String, tcx: TyCtxt<'_>) -> std::fmt::Result {
|
||||
pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
UrlFragment::Item(frag) => frag.render(s, tcx),
|
||||
UrlFragment::UserWritten(raw) => write!(s, "#{}", raw),
|
||||
@ -235,10 +235,10 @@ impl UrlFragment {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
||||
crate struct ItemFragment(FragmentKind, DefId);
|
||||
pub(crate) struct ItemFragment(FragmentKind, DefId);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
||||
crate enum FragmentKind {
|
||||
pub(crate) enum FragmentKind {
|
||||
Method,
|
||||
TyMethod,
|
||||
AssociatedConstant,
|
||||
@ -276,7 +276,7 @@ impl FragmentKind {
|
||||
|
||||
impl ItemFragment {
|
||||
/// Render the fragment, including the leading `#`.
|
||||
crate fn render(&self, s: &mut String, tcx: TyCtxt<'_>) -> std::fmt::Result {
|
||||
pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) -> std::fmt::Result {
|
||||
write!(s, "#")?;
|
||||
match *self {
|
||||
ItemFragment(kind, def_id) => {
|
||||
@ -954,7 +954,10 @@ struct PreprocessingInfo {
|
||||
}
|
||||
|
||||
// Not a typedef to avoid leaking several private structures from this module.
|
||||
crate struct PreprocessedMarkdownLink(Result<PreprocessingInfo, PreprocessingError>, MarkdownLink);
|
||||
pub(crate) struct PreprocessedMarkdownLink(
|
||||
Result<PreprocessingInfo, PreprocessingError>,
|
||||
MarkdownLink,
|
||||
);
|
||||
|
||||
/// Returns:
|
||||
/// - `None` if the link should be ignored.
|
||||
|
@ -21,7 +21,7 @@ use rustc_span::{Symbol, SyntaxContext};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::mem;
|
||||
|
||||
crate fn early_resolve_intra_doc_links(
|
||||
pub(crate) fn early_resolve_intra_doc_links(
|
||||
resolver: &mut Resolver<'_>,
|
||||
sess: &Session,
|
||||
krate: &ast::Crate,
|
||||
|
@ -12,13 +12,13 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
crate const COLLECT_TRAIT_IMPLS: Pass = Pass {
|
||||
pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass {
|
||||
name: "collect-trait-impls",
|
||||
run: collect_trait_impls,
|
||||
description: "retrieves trait impls for items in the crate",
|
||||
};
|
||||
|
||||
crate fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
let synth_impls = cx.sess().time("collect_synthetic_impls", || {
|
||||
let mut synth = SyntheticImplCollector { cx, impls: Vec::new() };
|
||||
synth.visit_crate(&krate);
|
||||
|
@ -11,7 +11,7 @@ use std::iter::Peekable;
|
||||
use std::ops::Range;
|
||||
use std::str::CharIndices;
|
||||
|
||||
crate const CHECK_INVALID_HTML_TAGS: Pass = Pass {
|
||||
pub(crate) const CHECK_INVALID_HTML_TAGS: Pass = Pass {
|
||||
name: "check-invalid-html-tags",
|
||||
run: check_invalid_html_tags,
|
||||
description: "detects invalid HTML tags in doc comments",
|
||||
@ -21,7 +21,7 @@ struct InvalidHtmlTagsLinter<'a, 'tcx> {
|
||||
cx: &'a mut DocContext<'tcx>,
|
||||
}
|
||||
|
||||
crate fn check_invalid_html_tags(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
pub(crate) fn check_invalid_html_tags(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
if cx.tcx.sess.is_nightly_build() {
|
||||
let mut coll = InvalidHtmlTagsLinter { cx };
|
||||
coll.visit_crate(&krate);
|
||||
|
@ -10,61 +10,61 @@ use crate::clean::{self, DocFragmentKind};
|
||||
use crate::core::DocContext;
|
||||
|
||||
mod stripper;
|
||||
crate use stripper::*;
|
||||
pub(crate) use stripper::*;
|
||||
|
||||
mod bare_urls;
|
||||
crate use self::bare_urls::CHECK_BARE_URLS;
|
||||
pub(crate) use self::bare_urls::CHECK_BARE_URLS;
|
||||
|
||||
mod strip_hidden;
|
||||
crate use self::strip_hidden::STRIP_HIDDEN;
|
||||
pub(crate) use self::strip_hidden::STRIP_HIDDEN;
|
||||
|
||||
mod strip_private;
|
||||
crate use self::strip_private::STRIP_PRIVATE;
|
||||
pub(crate) use self::strip_private::STRIP_PRIVATE;
|
||||
|
||||
mod strip_priv_imports;
|
||||
crate use self::strip_priv_imports::STRIP_PRIV_IMPORTS;
|
||||
pub(crate) use self::strip_priv_imports::STRIP_PRIV_IMPORTS;
|
||||
|
||||
mod propagate_doc_cfg;
|
||||
crate use self::propagate_doc_cfg::PROPAGATE_DOC_CFG;
|
||||
pub(crate) use self::propagate_doc_cfg::PROPAGATE_DOC_CFG;
|
||||
|
||||
crate mod collect_intra_doc_links;
|
||||
crate use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS;
|
||||
pub(crate) mod collect_intra_doc_links;
|
||||
pub(crate) use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS;
|
||||
|
||||
mod check_doc_test_visibility;
|
||||
crate use self::check_doc_test_visibility::CHECK_DOC_TEST_VISIBILITY;
|
||||
pub(crate) use self::check_doc_test_visibility::CHECK_DOC_TEST_VISIBILITY;
|
||||
|
||||
mod collect_trait_impls;
|
||||
crate use self::collect_trait_impls::COLLECT_TRAIT_IMPLS;
|
||||
pub(crate) use self::collect_trait_impls::COLLECT_TRAIT_IMPLS;
|
||||
|
||||
mod check_code_block_syntax;
|
||||
crate use self::check_code_block_syntax::CHECK_CODE_BLOCK_SYNTAX;
|
||||
pub(crate) use self::check_code_block_syntax::CHECK_CODE_BLOCK_SYNTAX;
|
||||
|
||||
mod calculate_doc_coverage;
|
||||
crate use self::calculate_doc_coverage::CALCULATE_DOC_COVERAGE;
|
||||
pub(crate) use self::calculate_doc_coverage::CALCULATE_DOC_COVERAGE;
|
||||
|
||||
mod html_tags;
|
||||
crate use self::html_tags::CHECK_INVALID_HTML_TAGS;
|
||||
pub(crate) use self::html_tags::CHECK_INVALID_HTML_TAGS;
|
||||
|
||||
/// A single pass over the cleaned documentation.
|
||||
///
|
||||
/// Runs in the compiler context, so it has access to types and traits and the like.
|
||||
#[derive(Copy, Clone)]
|
||||
crate struct Pass {
|
||||
crate name: &'static str,
|
||||
crate run: fn(clean::Crate, &mut DocContext<'_>) -> clean::Crate,
|
||||
crate description: &'static str,
|
||||
pub(crate) struct Pass {
|
||||
pub(crate) name: &'static str,
|
||||
pub(crate) run: fn(clean::Crate, &mut DocContext<'_>) -> clean::Crate,
|
||||
pub(crate) description: &'static str,
|
||||
}
|
||||
|
||||
/// In a list of passes, a pass that may or may not need to be run depending on options.
|
||||
#[derive(Copy, Clone)]
|
||||
crate struct ConditionalPass {
|
||||
crate pass: Pass,
|
||||
crate condition: Condition,
|
||||
pub(crate) struct ConditionalPass {
|
||||
pub(crate) pass: Pass,
|
||||
pub(crate) condition: Condition,
|
||||
}
|
||||
|
||||
/// How to decide whether to run a conditional pass.
|
||||
#[derive(Copy, Clone)]
|
||||
crate enum Condition {
|
||||
pub(crate) enum Condition {
|
||||
Always,
|
||||
/// When `--document-private-items` is passed.
|
||||
WhenDocumentPrivate,
|
||||
@ -75,7 +75,7 @@ crate enum Condition {
|
||||
}
|
||||
|
||||
/// The full list of passes.
|
||||
crate const PASSES: &[Pass] = &[
|
||||
pub(crate) const PASSES: &[Pass] = &[
|
||||
CHECK_DOC_TEST_VISIBILITY,
|
||||
STRIP_HIDDEN,
|
||||
STRIP_PRIVATE,
|
||||
@ -90,7 +90,7 @@ crate const PASSES: &[Pass] = &[
|
||||
];
|
||||
|
||||
/// The list of passes run by default.
|
||||
crate const DEFAULT_PASSES: &[ConditionalPass] = &[
|
||||
pub(crate) const DEFAULT_PASSES: &[ConditionalPass] = &[
|
||||
ConditionalPass::always(COLLECT_TRAIT_IMPLS),
|
||||
ConditionalPass::always(CHECK_DOC_TEST_VISIBILITY),
|
||||
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
|
||||
@ -104,29 +104,29 @@ crate const DEFAULT_PASSES: &[ConditionalPass] = &[
|
||||
];
|
||||
|
||||
/// The list of default passes run when `--doc-coverage` is passed to rustdoc.
|
||||
crate const COVERAGE_PASSES: &[ConditionalPass] = &[
|
||||
pub(crate) const COVERAGE_PASSES: &[ConditionalPass] = &[
|
||||
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
|
||||
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
|
||||
ConditionalPass::always(CALCULATE_DOC_COVERAGE),
|
||||
];
|
||||
|
||||
impl ConditionalPass {
|
||||
crate const fn always(pass: Pass) -> Self {
|
||||
pub(crate) const fn always(pass: Pass) -> Self {
|
||||
Self::new(pass, Always)
|
||||
}
|
||||
|
||||
crate const fn new(pass: Pass, condition: Condition) -> Self {
|
||||
pub(crate) const fn new(pass: Pass, condition: Condition) -> Self {
|
||||
ConditionalPass { pass, condition }
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the given default set of passes.
|
||||
crate fn defaults(show_coverage: bool) -> &'static [ConditionalPass] {
|
||||
pub(crate) fn defaults(show_coverage: bool) -> &'static [ConditionalPass] {
|
||||
if show_coverage { COVERAGE_PASSES } else { DEFAULT_PASSES }
|
||||
}
|
||||
|
||||
/// Returns a span encompassing all the given attributes.
|
||||
crate fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> {
|
||||
pub(crate) fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> {
|
||||
if attrs.doc_strings.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@ -143,7 +143,7 @@ crate fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> {
|
||||
/// This method will return `None` if we cannot construct a span from the source map or if the
|
||||
/// attributes are not all sugared doc comments. It's difficult to calculate the correct span in
|
||||
/// that case due to escaping and other source features.
|
||||
crate fn source_span_for_markdown_range(
|
||||
pub(crate) fn source_span_for_markdown_range(
|
||||
tcx: TyCtxt<'_>,
|
||||
markdown: &str,
|
||||
md_range: &Range<usize>,
|
||||
|
@ -7,13 +7,13 @@ use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::passes::Pass;
|
||||
|
||||
crate const PROPAGATE_DOC_CFG: Pass = Pass {
|
||||
pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
|
||||
name: "propagate-doc-cfg",
|
||||
run: propagate_doc_cfg,
|
||||
description: "propagates `#[doc(cfg(...))]` to child items",
|
||||
};
|
||||
|
||||
crate fn propagate_doc_cfg(cr: Crate, _: &mut DocContext<'_>) -> Crate {
|
||||
pub(crate) fn propagate_doc_cfg(cr: Crate, _: &mut DocContext<'_>) -> Crate {
|
||||
CfgPropagator { parent_cfg: None }.fold_crate(cr)
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,14 @@ use crate::core::DocContext;
|
||||
use crate::fold::{strip_item, DocFolder};
|
||||
use crate::passes::{ImplStripper, Pass};
|
||||
|
||||
crate const STRIP_HIDDEN: Pass = Pass {
|
||||
pub(crate) const STRIP_HIDDEN: Pass = Pass {
|
||||
name: "strip-hidden",
|
||||
run: strip_hidden,
|
||||
description: "strips all `#[doc(hidden)]` items from the output",
|
||||
};
|
||||
|
||||
/// Strip items marked `#[doc(hidden)]`
|
||||
crate fn strip_hidden(krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
|
||||
pub(crate) fn strip_hidden(krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
|
||||
let mut retained = ItemIdSet::default();
|
||||
|
||||
// strip all #[doc(hidden)] items
|
||||
|
@ -5,12 +5,12 @@ use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::passes::{ImportStripper, Pass};
|
||||
|
||||
crate const STRIP_PRIV_IMPORTS: Pass = Pass {
|
||||
pub(crate) const STRIP_PRIV_IMPORTS: Pass = Pass {
|
||||
name: "strip-priv-imports",
|
||||
run: strip_priv_imports,
|
||||
description: "strips all private import statements (`use`, `extern crate`) from a crate",
|
||||
};
|
||||
|
||||
crate fn strip_priv_imports(krate: clean::Crate, _: &mut DocContext<'_>) -> clean::Crate {
|
||||
pub(crate) fn strip_priv_imports(krate: clean::Crate, _: &mut DocContext<'_>) -> clean::Crate {
|
||||
ImportStripper.fold_crate(krate)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::passes::{ImplStripper, ImportStripper, Pass, Stripper};
|
||||
|
||||
crate const STRIP_PRIVATE: Pass = Pass {
|
||||
pub(crate) const STRIP_PRIVATE: Pass = Pass {
|
||||
name: "strip-private",
|
||||
run: strip_private,
|
||||
description: "strips all private items from a crate which cannot be seen externally, \
|
||||
@ -14,7 +14,7 @@ crate const STRIP_PRIVATE: Pass = Pass {
|
||||
|
||||
/// Strip private items from the point of view of a crate or externally from a
|
||||
/// crate, specified by the `xcrate` flag.
|
||||
crate fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
|
||||
pub(crate) fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
|
||||
// This stripper collects all *retained* nodes.
|
||||
let mut retained = ItemIdSet::default();
|
||||
|
||||
|
@ -7,10 +7,10 @@ use crate::clean::{self, Item, ItemIdSet};
|
||||
use crate::fold::{strip_item, DocFolder};
|
||||
use crate::formats::cache::Cache;
|
||||
|
||||
crate struct Stripper<'a> {
|
||||
crate retained: &'a mut ItemIdSet,
|
||||
crate access_levels: &'a AccessLevels<DefId>,
|
||||
crate update_retained: bool,
|
||||
pub(crate) struct Stripper<'a> {
|
||||
pub(crate) retained: &'a mut ItemIdSet,
|
||||
pub(crate) access_levels: &'a AccessLevels<DefId>,
|
||||
pub(crate) update_retained: bool,
|
||||
}
|
||||
|
||||
impl<'a> DocFolder for Stripper<'a> {
|
||||
@ -116,9 +116,9 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||
}
|
||||
|
||||
/// This stripper discards all impls which reference stripped items
|
||||
crate struct ImplStripper<'a> {
|
||||
crate retained: &'a ItemIdSet,
|
||||
crate cache: &'a Cache,
|
||||
pub(crate) struct ImplStripper<'a> {
|
||||
pub(crate) retained: &'a ItemIdSet,
|
||||
pub(crate) cache: &'a Cache,
|
||||
}
|
||||
|
||||
impl<'a> DocFolder for ImplStripper<'a> {
|
||||
@ -159,7 +159,7 @@ impl<'a> DocFolder for ImplStripper<'a> {
|
||||
}
|
||||
|
||||
/// This stripper discards all private import statements (`use`, `extern crate`)
|
||||
crate struct ImportStripper;
|
||||
pub(crate) struct ImportStripper;
|
||||
|
||||
impl DocFolder for ImportStripper {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
|
@ -31,14 +31,14 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
crate struct ScrapeExamplesOptions {
|
||||
pub(crate) struct ScrapeExamplesOptions {
|
||||
output_path: PathBuf,
|
||||
target_crates: Vec<String>,
|
||||
crate scrape_tests: bool,
|
||||
pub(crate) scrape_tests: bool,
|
||||
}
|
||||
|
||||
impl ScrapeExamplesOptions {
|
||||
crate fn new(
|
||||
pub(crate) fn new(
|
||||
matches: &getopts::Matches,
|
||||
diag: &rustc_errors::Handler,
|
||||
) -> Result<Option<Self>, i32> {
|
||||
@ -65,9 +65,9 @@ impl ScrapeExamplesOptions {
|
||||
}
|
||||
|
||||
#[derive(Encodable, Decodable, Debug, Clone)]
|
||||
crate struct SyntaxRange {
|
||||
crate byte_span: (u32, u32),
|
||||
crate line_span: (usize, usize),
|
||||
pub(crate) struct SyntaxRange {
|
||||
pub(crate) byte_span: (u32, u32),
|
||||
pub(crate) line_span: (usize, usize),
|
||||
}
|
||||
|
||||
impl SyntaxRange {
|
||||
@ -83,10 +83,10 @@ impl SyntaxRange {
|
||||
}
|
||||
|
||||
#[derive(Encodable, Decodable, Debug, Clone)]
|
||||
crate struct CallLocation {
|
||||
crate call_expr: SyntaxRange,
|
||||
crate call_ident: SyntaxRange,
|
||||
crate enclosing_item: SyntaxRange,
|
||||
pub(crate) struct CallLocation {
|
||||
pub(crate) call_expr: SyntaxRange,
|
||||
pub(crate) call_ident: SyntaxRange,
|
||||
pub(crate) enclosing_item: SyntaxRange,
|
||||
}
|
||||
|
||||
impl CallLocation {
|
||||
@ -105,15 +105,15 @@ impl CallLocation {
|
||||
}
|
||||
|
||||
#[derive(Encodable, Decodable, Debug, Clone)]
|
||||
crate struct CallData {
|
||||
crate locations: Vec<CallLocation>,
|
||||
crate url: String,
|
||||
crate display_name: String,
|
||||
crate edition: Edition,
|
||||
pub(crate) struct CallData {
|
||||
pub(crate) locations: Vec<CallLocation>,
|
||||
pub(crate) url: String,
|
||||
pub(crate) display_name: String,
|
||||
pub(crate) edition: Edition,
|
||||
}
|
||||
|
||||
crate type FnCallLocations = FxHashMap<PathBuf, CallData>;
|
||||
crate type AllCallLocations = FxHashMap<DefPathHash, FnCallLocations>;
|
||||
pub(crate) type FnCallLocations = FxHashMap<PathBuf, CallData>;
|
||||
pub(crate) type AllCallLocations = FxHashMap<DefPathHash, FnCallLocations>;
|
||||
|
||||
/// Visitor for traversing a crate and finding instances of function calls.
|
||||
struct FindCalls<'a, 'tcx> {
|
||||
@ -270,7 +270,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
crate fn run(
|
||||
pub(crate) fn run(
|
||||
krate: clean::Crate,
|
||||
mut renderopts: config::RenderOptions,
|
||||
cache: formats::cache::Cache,
|
||||
@ -328,7 +328,7 @@ crate fn run(
|
||||
}
|
||||
|
||||
// Note: the Handler must be passed in explicitly because sess isn't available while parsing options
|
||||
crate fn load_call_locations(
|
||||
pub(crate) fn load_call_locations(
|
||||
with_examples: Vec<String>,
|
||||
diag: &rustc_errors::Handler,
|
||||
) -> Result<AllCallLocations, i32> {
|
||||
|
@ -9,9 +9,9 @@ use rustc_errors::Handler;
|
||||
mod tests;
|
||||
|
||||
#[derive(Debug, Clone, Eq)]
|
||||
crate struct CssPath {
|
||||
crate name: String,
|
||||
crate children: FxHashSet<CssPath>,
|
||||
pub(crate) struct CssPath {
|
||||
pub(crate) name: String,
|
||||
pub(crate) children: FxHashSet<CssPath>,
|
||||
}
|
||||
|
||||
// This PartialEq implementation IS NOT COMMUTATIVE!!!
|
||||
@ -214,7 +214,7 @@ fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> FxHashSet<CssPath> {
|
||||
paths.iter().cloned().collect()
|
||||
}
|
||||
|
||||
crate fn load_css_paths(v: &[u8]) -> CssPath {
|
||||
pub(crate) fn load_css_paths(v: &[u8]) -> CssPath {
|
||||
let events = load_css_events(v);
|
||||
let mut pos = 0;
|
||||
|
||||
@ -223,7 +223,7 @@ crate fn load_css_paths(v: &[u8]) -> CssPath {
|
||||
parent
|
||||
}
|
||||
|
||||
crate fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec<String>) {
|
||||
pub(crate) fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec<String>) {
|
||||
if against.name == other.name {
|
||||
for child in &against.children {
|
||||
let mut found = false;
|
||||
@ -250,7 +250,7 @@ crate fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec<String>
|
||||
}
|
||||
}
|
||||
|
||||
crate fn test_theme_against<P: AsRef<Path>>(
|
||||
pub(crate) fn test_theme_against<P: AsRef<Path>>(
|
||||
f: &P,
|
||||
against: &CssPath,
|
||||
diag: &Handler,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::clean::*;
|
||||
|
||||
crate trait DocVisitor: Sized {
|
||||
pub(crate) trait DocVisitor: Sized {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
self.visit_item_recur(item)
|
||||
}
|
||||
|
@ -21,22 +21,22 @@ use crate::core;
|
||||
/// This module is used to store stuff from Rust's AST in a more convenient
|
||||
/// manner (and with prettier names) before cleaning.
|
||||
#[derive(Debug)]
|
||||
crate struct Module<'hir> {
|
||||
crate name: Symbol,
|
||||
crate where_inner: Span,
|
||||
crate mods: Vec<Module<'hir>>,
|
||||
crate id: hir::HirId,
|
||||
pub(crate) struct Module<'hir> {
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) where_inner: Span,
|
||||
pub(crate) mods: Vec<Module<'hir>>,
|
||||
pub(crate) id: hir::HirId,
|
||||
// (item, renamed)
|
||||
crate items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
|
||||
crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
|
||||
pub(crate) items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
|
||||
pub(crate) foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
|
||||
}
|
||||
|
||||
impl Module<'_> {
|
||||
crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Self {
|
||||
pub(crate) fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Self {
|
||||
Module { name, id, where_inner, mods: Vec::new(), items: Vec::new(), foreigns: Vec::new() }
|
||||
}
|
||||
|
||||
crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
pub(crate) fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
tcx.hir().span(self.id)
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<Symbol> {
|
||||
std::iter::once(crate_name).chain(relative).collect()
|
||||
}
|
||||
|
||||
crate fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool {
|
||||
pub(crate) fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool {
|
||||
while let Some(id) = tcx.hir().get_enclosing_scope(node) {
|
||||
node = id;
|
||||
if tcx.hir().attrs(node).lists(sym::doc).has_word(sym::hidden) {
|
||||
@ -61,7 +61,7 @@ crate fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool {
|
||||
// Also, is there some reason that this doesn't use the 'visit'
|
||||
// framework from syntax?.
|
||||
|
||||
crate struct RustdocVisitor<'a, 'tcx> {
|
||||
pub(crate) struct RustdocVisitor<'a, 'tcx> {
|
||||
cx: &'a mut core::DocContext<'tcx>,
|
||||
view_item_stack: FxHashSet<hir::HirId>,
|
||||
inlining: bool,
|
||||
@ -71,7 +71,7 @@ crate struct RustdocVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
crate fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
|
||||
pub(crate) fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
|
||||
// If the root is re-exported, terminate all recursion.
|
||||
let mut stack = FxHashSet::default();
|
||||
stack.insert(hir::CRATE_HIR_ID);
|
||||
@ -89,7 +89,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
self.exact_paths.entry(did).or_insert_with(|| def_id_to_path(tcx, did));
|
||||
}
|
||||
|
||||
crate fn visit(mut self) -> Module<'tcx> {
|
||||
pub(crate) fn visit(mut self) -> Module<'tcx> {
|
||||
let mut top_level_module = self.visit_mod_contents(
|
||||
hir::CRATE_HIR_ID,
|
||||
self.cx.tcx.hir().root_module(),
|
||||
|
@ -8,7 +8,7 @@ use rustc_middle::ty::TyCtxt;
|
||||
|
||||
/// Similar to `librustc_privacy::EmbargoVisitor`, but also takes
|
||||
/// specific rustdoc annotations into account (i.e., `doc(hidden)`)
|
||||
crate struct LibEmbargoVisitor<'a, 'tcx> {
|
||||
pub(crate) struct LibEmbargoVisitor<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
// Accessibility levels for reachable nodes
|
||||
access_levels: &'a mut AccessLevels<DefId>,
|
||||
@ -19,7 +19,7 @@ crate struct LibEmbargoVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
|
||||
crate fn new(cx: &'a mut crate::core::DocContext<'tcx>) -> LibEmbargoVisitor<'a, 'tcx> {
|
||||
pub(crate) fn new(cx: &'a mut crate::core::DocContext<'tcx>) -> LibEmbargoVisitor<'a, 'tcx> {
|
||||
LibEmbargoVisitor {
|
||||
tcx: cx.tcx,
|
||||
access_levels: &mut cx.cache.access_levels,
|
||||
@ -28,7 +28,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn visit_lib(&mut self, cnum: CrateNum) {
|
||||
pub(crate) fn visit_lib(&mut self, cnum: CrateNum) {
|
||||
let did = cnum.as_def_id();
|
||||
self.update(did, Some(AccessLevel::Public));
|
||||
self.visit_mod(did);
|
||||
@ -48,7 +48,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
crate fn visit_mod(&mut self, def_id: DefId) {
|
||||
pub(crate) fn visit_mod(&mut self, def_id: DefId) {
|
||||
if !self.visited_mods.insert(def_id) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
// compile-flags: --document-private-items
|
||||
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
// @!has 'foo/index.html' '//a[@href="struct.FooPublic.html"]/..' 'FooPublic 🔒'
|
||||
@ -9,7 +7,7 @@
|
||||
pub struct FooPublic;
|
||||
// @has 'foo/index.html' '//a[@href="struct.FooJustCrate.html"]/..' 'FooJustCrate 🔒'
|
||||
// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate'
|
||||
crate struct FooJustCrate;
|
||||
pub(crate) struct FooJustCrate;
|
||||
// @has 'foo/index.html' '//a[@href="struct.FooPubCrate.html"]/..' 'FooPubCrate 🔒'
|
||||
// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate'
|
||||
pub(crate) struct FooPubCrate;
|
||||
|
@ -2,7 +2,6 @@
|
||||
// check-pass
|
||||
|
||||
#![warn(dead_code)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
struct Foo {
|
||||
a: i32, //~ WARNING: field is never read
|
||||
@ -28,12 +27,12 @@ impl Bar1 {
|
||||
pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
|
||||
}
|
||||
|
||||
crate struct Foo2 {
|
||||
pub(crate) struct Foo2 {
|
||||
a: i32, //~ WARNING: field is never read
|
||||
pub b: i32, //~ WARNING: field is never read
|
||||
}
|
||||
|
||||
crate struct Bar2;
|
||||
pub(crate) struct Bar2;
|
||||
|
||||
impl Bar2 {
|
||||
fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: field is never read: `a`
|
||||
--> $DIR/issue-85255.rs:8:5
|
||||
--> $DIR/issue-85255.rs:7:5
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^^^^^^
|
||||
@ -11,67 +11,67 @@ LL | #![warn(dead_code)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: field is never read: `b`
|
||||
--> $DIR/issue-85255.rs:9:5
|
||||
--> $DIR/issue-85255.rs:8:5
|
||||
|
|
||||
LL | pub b: i32,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: associated function is never used: `a`
|
||||
--> $DIR/issue-85255.rs:15:8
|
||||
--> $DIR/issue-85255.rs:14:8
|
||||
|
|
||||
LL | fn a(&self) -> i32 { 5 }
|
||||
| ^
|
||||
|
||||
warning: associated function is never used: `b`
|
||||
--> $DIR/issue-85255.rs:16:12
|
||||
--> $DIR/issue-85255.rs:15:12
|
||||
|
|
||||
LL | pub fn b(&self) -> i32 { 6 }
|
||||
| ^
|
||||
|
||||
warning: field is never read: `a`
|
||||
--> $DIR/issue-85255.rs:19:5
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^^^^^^
|
||||
|
||||
warning: field is never read: `b`
|
||||
--> $DIR/issue-85255.rs:20:5
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^^^^^^
|
||||
|
||||
warning: field is never read: `b`
|
||||
--> $DIR/issue-85255.rs:21:5
|
||||
|
|
||||
LL | pub b: i32,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: associated function is never used: `a`
|
||||
--> $DIR/issue-85255.rs:27:8
|
||||
--> $DIR/issue-85255.rs:26:8
|
||||
|
|
||||
LL | fn a(&self) -> i32 { 5 }
|
||||
| ^
|
||||
|
||||
warning: associated function is never used: `b`
|
||||
--> $DIR/issue-85255.rs:28:12
|
||||
--> $DIR/issue-85255.rs:27:12
|
||||
|
|
||||
LL | pub fn b(&self) -> i32 { 6 }
|
||||
| ^
|
||||
|
||||
warning: field is never read: `a`
|
||||
--> $DIR/issue-85255.rs:32:5
|
||||
--> $DIR/issue-85255.rs:31:5
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^^^^^^
|
||||
|
||||
warning: field is never read: `b`
|
||||
--> $DIR/issue-85255.rs:33:5
|
||||
--> $DIR/issue-85255.rs:32:5
|
||||
|
|
||||
LL | pub b: i32,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: associated function is never used: `a`
|
||||
--> $DIR/issue-85255.rs:39:8
|
||||
--> $DIR/issue-85255.rs:38:8
|
||||
|
|
||||
LL | fn a(&self) -> i32 { 5 }
|
||||
| ^
|
||||
|
||||
warning: associated function is never used: `b`
|
||||
--> $DIR/issue-85255.rs:40:12
|
||||
--> $DIR/issue-85255.rs:39:12
|
||||
|
|
||||
LL | pub fn b(&self) -> i32 { 6 }
|
||||
| ^
|
||||
|
@ -1,7 +1,7 @@
|
||||
// edition:2018
|
||||
|
||||
#![deny(unused_extern_crates)]
|
||||
#![feature(test, rustc_private, crate_visibility_modifier)]
|
||||
#![feature(test, rustc_private)]
|
||||
|
||||
extern crate libc;
|
||||
//~^ ERROR unused extern crate
|
||||
@ -21,7 +21,7 @@ pub extern crate alloc;
|
||||
|
||||
pub(crate) extern crate alloc as a;
|
||||
|
||||
crate extern crate alloc as b;
|
||||
pub(crate) extern crate alloc as b;
|
||||
|
||||
mod foo {
|
||||
pub(in crate::foo) extern crate alloc as c;
|
||||
|
@ -1,72 +0,0 @@
|
||||
// This is just like unreachable_pub.rs, but without the
|
||||
// `crate_visibility_modifier` feature (so that we can test the suggestions to
|
||||
// use `pub(crate)` that are given when that feature is off, as opposed to the
|
||||
// suggestions to use `crate` given when it is on). When that feature becomes
|
||||
// stable, this test can be deleted.
|
||||
|
||||
// check-pass
|
||||
|
||||
|
||||
#![warn(unreachable_pub)]
|
||||
|
||||
mod private_mod {
|
||||
// non-leaked `pub` items in private module should be linted
|
||||
pub use std::fmt; //~ WARNING unreachable_pub
|
||||
pub use std::env::{Args}; // braced-use has different item spans than unbraced
|
||||
//~^ WARNING unreachable_pub
|
||||
|
||||
pub struct Hydrogen { //~ WARNING unreachable_pub
|
||||
// `pub` struct fields, too
|
||||
pub neutrons: usize, //~ WARNING unreachable_pub
|
||||
// (... but not more-restricted fields)
|
||||
pub(crate) electrons: usize
|
||||
}
|
||||
impl Hydrogen {
|
||||
// impls, too
|
||||
pub fn count_neutrons(&self) -> usize { self.neutrons } //~ WARNING unreachable_pub
|
||||
pub(crate) fn count_electrons(&self) -> usize { self.electrons }
|
||||
}
|
||||
impl Clone for Hydrogen {
|
||||
fn clone(&self) -> Hydrogen {
|
||||
Hydrogen { neutrons: self.neutrons, electrons: self.electrons }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Helium {} //~ WARNING unreachable_pub
|
||||
pub union Lithium { c1: usize, c2: u8 } //~ WARNING unreachable_pub
|
||||
pub fn beryllium() {} //~ WARNING unreachable_pub
|
||||
pub trait Boron {} //~ WARNING unreachable_pub
|
||||
pub const CARBON: usize = 1; //~ WARNING unreachable_pub
|
||||
pub static NITROGEN: usize = 2; //~ WARNING unreachable_pub
|
||||
pub type Oxygen = bool; //~ WARNING unreachable_pub
|
||||
|
||||
macro_rules! define_empty_struct_with_visibility {
|
||||
($visibility: vis, $name: ident) => { $visibility struct $name {} }
|
||||
//~^ WARNING unreachable_pub
|
||||
}
|
||||
define_empty_struct_with_visibility!(pub, Fluorine);
|
||||
|
||||
extern "C" {
|
||||
pub fn catalyze() -> bool; //~ WARNING unreachable_pub
|
||||
}
|
||||
|
||||
// items leaked through signatures (see `get_neon` below) are OK
|
||||
pub struct Neon {}
|
||||
|
||||
// crate-visible items are OK
|
||||
pub(crate) struct Sodium {}
|
||||
}
|
||||
|
||||
pub mod public_mod {
|
||||
// module is public: these are OK, too
|
||||
pub struct Magnesium {}
|
||||
pub(crate) struct Aluminum {}
|
||||
}
|
||||
|
||||
pub fn get_neon() -> private_mod::Neon {
|
||||
private_mod::Neon {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = get_neon();
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:14:5
|
||||
|
|
||||
LL | pub use std::fmt;
|
||||
| ---^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:10:9
|
||||
|
|
||||
LL | #![warn(unreachable_pub)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:15:24
|
||||
|
|
||||
LL | pub use std::env::{Args}; // braced-use has different item spans than unbraced
|
||||
| --- ^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:18:5
|
||||
|
|
||||
LL | pub struct Hydrogen {
|
||||
| ---^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` field
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:20:9
|
||||
|
|
||||
LL | pub neutrons: usize,
|
||||
| ---^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:26:9
|
||||
|
|
||||
LL | pub fn count_neutrons(&self) -> usize { self.neutrons }
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:35:5
|
||||
|
|
||||
LL | pub enum Helium {}
|
||||
| ---^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:36:5
|
||||
|
|
||||
LL | pub union Lithium { c1: usize, c2: u8 }
|
||||
| ---^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:37:5
|
||||
|
|
||||
LL | pub fn beryllium() {}
|
||||
| ---^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:38:5
|
||||
|
|
||||
LL | pub trait Boron {}
|
||||
| ---^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:39:5
|
||||
|
|
||||
LL | pub const CARBON: usize = 1;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:40:5
|
||||
|
|
||||
LL | pub static NITROGEN: usize = 2;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:41:5
|
||||
|
|
||||
LL | pub type Oxygen = bool;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:44:47
|
||||
|
|
||||
LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | define_empty_struct_with_visibility!(pub, Fluorine);
|
||||
| ---------------------------------------------------
|
||||
| | |
|
||||
| | help: consider restricting its visibility: `pub(crate)`
|
||||
| in this macro invocation
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
= note: this warning originates in the macro `define_empty_struct_with_visibility` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub-pub_crate.rs:50:9
|
||||
|
|
||||
LL | pub fn catalyze() -> bool;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: 14 warnings emitted
|
||||
|
@ -1,7 +1,5 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
#![allow(unused)]
|
||||
#![warn(unreachable_pub)]
|
||||
|
||||
@ -15,12 +13,12 @@ mod private_mod {
|
||||
// `pub` struct fields, too
|
||||
pub neutrons: usize, //~ WARNING unreachable_pub
|
||||
// (... but not more-restricted fields)
|
||||
crate electrons: usize
|
||||
pub(crate) electrons: usize
|
||||
}
|
||||
impl Hydrogen {
|
||||
// impls, too
|
||||
pub fn count_neutrons(&self) -> usize { self.neutrons } //~ WARNING unreachable_pub
|
||||
crate fn count_electrons(&self) -> usize { self.electrons }
|
||||
pub(crate) fn count_electrons(&self) -> usize { self.electrons }
|
||||
}
|
||||
impl Clone for Hydrogen {
|
||||
fn clone(&self) -> Hydrogen {
|
||||
@ -50,13 +48,13 @@ mod private_mod {
|
||||
pub struct Neon {}
|
||||
|
||||
// crate-visible items are OK
|
||||
crate struct Sodium {}
|
||||
pub(crate) struct Sodium {}
|
||||
}
|
||||
|
||||
pub mod public_mod {
|
||||
// module is public: these are OK, too
|
||||
pub struct Magnesium {}
|
||||
crate struct Aluminum {}
|
||||
pub(crate) struct Aluminum {}
|
||||
}
|
||||
|
||||
pub fn get_neon() -> private_mod::Neon {
|
||||
|
@ -1,126 +1,126 @@
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:10:5
|
||||
--> $DIR/unreachable_pub.rs:8:5
|
||||
|
|
||||
LL | pub use std::fmt;
|
||||
| ---^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unreachable_pub.rs:6:9
|
||||
--> $DIR/unreachable_pub.rs:4:9
|
||||
|
|
||||
LL | #![warn(unreachable_pub)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:11:24
|
||||
--> $DIR/unreachable_pub.rs:9:24
|
||||
|
|
||||
LL | pub use std::env::{Args}; // braced-use has different item spans than unbraced
|
||||
| --- ^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:14:5
|
||||
--> $DIR/unreachable_pub.rs:12:5
|
||||
|
|
||||
LL | pub struct Hydrogen {
|
||||
| ---^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` field
|
||||
--> $DIR/unreachable_pub.rs:16:9
|
||||
--> $DIR/unreachable_pub.rs:14:9
|
||||
|
|
||||
LL | pub neutrons: usize,
|
||||
| ---^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:22:9
|
||||
--> $DIR/unreachable_pub.rs:20:9
|
||||
|
|
||||
LL | pub fn count_neutrons(&self) -> usize { self.neutrons }
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:31:5
|
||||
--> $DIR/unreachable_pub.rs:29:5
|
||||
|
|
||||
LL | pub enum Helium {}
|
||||
| ---^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:30:5
|
||||
|
|
||||
LL | pub union Lithium { c1: usize, c2: u8 }
|
||||
| ---^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:31:5
|
||||
|
|
||||
LL | pub fn beryllium() {}
|
||||
| ---^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:32:5
|
||||
|
|
||||
LL | pub union Lithium { c1: usize, c2: u8 }
|
||||
| ---^^^^^^^^^^^^^^
|
||||
LL | pub trait Boron {}
|
||||
| ---^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:33:5
|
||||
|
|
||||
LL | pub fn beryllium() {}
|
||||
| ---^^^^^^^^^^^^^^^
|
||||
LL | pub const CARBON: usize = 1;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:34:5
|
||||
|
|
||||
LL | pub trait Boron {}
|
||||
| ---^^^^^^^^^^^^
|
||||
LL | pub static NITROGEN: usize = 2;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:35:5
|
||||
|
|
||||
LL | pub const CARBON: usize = 1;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:36:5
|
||||
|
|
||||
LL | pub static NITROGEN: usize = 2;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:37:5
|
||||
|
|
||||
LL | pub type Oxygen = bool;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:40:47
|
||||
--> $DIR/unreachable_pub.rs:38:47
|
||||
|
|
||||
LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -128,19 +128,19 @@ LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} }
|
||||
LL | define_empty_struct_with_visibility!(pub, Fluorine);
|
||||
| ---------------------------------------------------
|
||||
| | |
|
||||
| | help: consider restricting its visibility: `crate`
|
||||
| | help: consider restricting its visibility: `pub(crate)`
|
||||
| in this macro invocation
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
= note: this warning originates in the macro `define_empty_struct_with_visibility` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: unreachable `pub` item
|
||||
--> $DIR/unreachable_pub.rs:46:9
|
||||
--> $DIR/unreachable_pub.rs:44:9
|
||||
|
|
||||
LL | pub fn catalyze() -> bool;
|
||||
| ---^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: consider restricting its visibility: `crate`
|
||||
| help: consider restricting its visibility: `pub(crate)`
|
||||
|
|
||||
= help: or consider exporting it for use by other crates
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-pass
|
||||
#![allow(dead_code, unused_imports, unused_macro_rules)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
/**
|
||||
Ensure that `:vis` matches can be captured in existing positions, and passed
|
||||
@ -56,15 +55,15 @@ mod with_pub_restricted {
|
||||
}
|
||||
|
||||
mod with_crate {
|
||||
vis_passthru! { crate const A: i32 = 0; }
|
||||
vis_passthru! { crate enum B {} }
|
||||
vis_passthru! { crate extern "C" fn c() {} }
|
||||
vis_passthru! { crate mod d {} }
|
||||
vis_passthru! { crate static E: i32 = 0; }
|
||||
vis_passthru! { crate struct F; }
|
||||
vis_passthru! { crate trait G {} }
|
||||
vis_passthru! { crate type H = i32; }
|
||||
vis_passthru! { crate use A as I; }
|
||||
vis_passthru! { pub(crate) const A: i32 = 0; }
|
||||
vis_passthru! { pub(crate) enum B {} }
|
||||
vis_passthru! { pub(crate) extern "C" fn c() {} }
|
||||
vis_passthru! { pub(crate) mod d {} }
|
||||
vis_passthru! { pub(crate) static E: i32 = 0; }
|
||||
vis_passthru! { pub(crate) struct F; }
|
||||
vis_passthru! { pub(crate) trait G {} }
|
||||
vis_passthru! { pub(crate) type H = i32; }
|
||||
vis_passthru! { pub(crate) use A as I; }
|
||||
}
|
||||
|
||||
mod garden {
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
#[deny(unused_imports)]
|
||||
mod rank {
|
||||
pub use self::Professor::*;
|
||||
@ -31,7 +29,7 @@ mod rank {
|
||||
MasterChief
|
||||
}
|
||||
|
||||
crate enum Crewman {
|
||||
pub(crate) enum Crewman {
|
||||
Recruit,
|
||||
Apprentice,
|
||||
Full
|
||||
|
@ -1,47 +1,47 @@
|
||||
error[E0364]: `JuniorGrade` is private, and cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:32
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: consider marking `JuniorGrade` as `pub` in the imported module
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:32
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error[E0364]: `Full` is private, and cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:45
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^
|
||||
|
|
||||
note: consider marking `Full` as `pub` in the imported module
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:45
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^
|
||||
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:13
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:3:13
|
||||
|
|
||||
LL | pub use self::Professor::*;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:3:8
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:1:8
|
||||
|
|
||||
LL | #[deny(unused_imports)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:8:13
|
||||
|
|
||||
LL | pub use self::PettyOfficer::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:12:13
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13
|
||||
|
|
||||
LL | pub use self::Crewman::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
@ -1,16 +1,14 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
pub(crate) struct Crate;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Universe {
|
||||
pub x: i32,
|
||||
pub(crate) y: i32,
|
||||
crate z: i32,
|
||||
pub(crate) z: i32,
|
||||
}
|
||||
|
||||
impl Universe {
|
||||
pub fn f(&self) {}
|
||||
pub(crate) fn g(&self) {}
|
||||
crate fn h(&self) {}
|
||||
pub(crate) fn h(&self) {}
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
mod foo {
|
||||
struct Priv;
|
||||
mod bar {
|
||||
use foo::Priv;
|
||||
pub(super) fn f(_: Priv) {}
|
||||
pub(crate) fn g(_: Priv) {} //~ ERROR E0446
|
||||
crate fn h(_: Priv) {} //~ ERROR E0446
|
||||
pub(crate) fn h(_: Priv) {} //~ ERROR E0446
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0446]: private type `Priv` in public interface
|
||||
--> $DIR/private-in-public.rs:8:9
|
||||
--> $DIR/private-in-public.rs:6:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ------------ `Priv` declared as private
|
||||
@ -8,13 +8,13 @@ LL | pub(crate) fn g(_: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
||||
error[E0446]: private type `Priv` in public interface
|
||||
--> $DIR/private-in-public.rs:9:9
|
||||
--> $DIR/private-in-public.rs:7:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | crate fn h(_: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
LL | pub(crate) fn h(_: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -29,7 +29,7 @@ LL | use pub_restricted::Crate;
|
||||
| ^^^^^ private struct
|
||||
|
|
||||
note: the struct `Crate` is defined here
|
||||
--> $DIR/auxiliary/pub_restricted.rs:3:1
|
||||
--> $DIR/auxiliary/pub_restricted.rs:1:1
|
||||
|
|
||||
LL | pub(crate) struct Crate;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -88,7 +88,7 @@ error[E0624]: associated function `g` is private
|
||||
LL | u.g();
|
||||
| ^ private associated function
|
||||
|
|
||||
::: $DIR/auxiliary/pub_restricted.rs:14:5
|
||||
::: $DIR/auxiliary/pub_restricted.rs:12:5
|
||||
|
|
||||
LL | pub(crate) fn g(&self) {}
|
||||
| ---------------------- private associated function defined here
|
||||
@ -99,10 +99,10 @@ error[E0624]: associated function `h` is private
|
||||
LL | u.h();
|
||||
| ^ private associated function
|
||||
|
|
||||
::: $DIR/auxiliary/pub_restricted.rs:15:5
|
||||
::: $DIR/auxiliary/pub_restricted.rs:13:5
|
||||
|
|
||||
LL | crate fn h(&self) {}
|
||||
| ----------------- private associated function defined here
|
||||
LL | pub(crate) fn h(&self) {}
|
||||
| ---------------------- private associated function defined here
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
// edition:2018
|
||||
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
mod bar {
|
||||
crate struct Foo;
|
||||
pub(crate) struct Foo;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0425]: cannot find value `Foo` in this scope
|
||||
--> $DIR/crate-in-paths.rs:10:5
|
||||
--> $DIR/crate-in-paths.rs:8:5
|
||||
|
|
||||
LL | Foo;
|
||||
| ^^^ not found in this scope
|
||||
|
@ -1,14 +1,14 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(rust_2018_preview, crate_visibility_modifier)]
|
||||
#![feature(rust_2018_preview)]
|
||||
#![deny(absolute_paths_not_starting_with_crate)]
|
||||
|
||||
mod foo {
|
||||
crate trait Foo {
|
||||
pub(crate) trait Foo {
|
||||
type Bar;
|
||||
}
|
||||
|
||||
crate struct Baz {}
|
||||
pub(crate) struct Baz {}
|
||||
|
||||
impl Foo for Baz {
|
||||
type Bar = ();
|
||||
|
@ -1,14 +1,14 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(rust_2018_preview, crate_visibility_modifier)]
|
||||
#![feature(rust_2018_preview)]
|
||||
#![deny(absolute_paths_not_starting_with_crate)]
|
||||
|
||||
mod foo {
|
||||
crate trait Foo {
|
||||
pub(crate) trait Foo {
|
||||
type Bar;
|
||||
}
|
||||
|
||||
crate struct Baz {}
|
||||
pub(crate) struct Baz {}
|
||||
|
||||
impl Foo for Baz {
|
||||
type Bar = ();
|
||||
|
@ -1,16 +1,16 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(rust_2018_preview, crate_visibility_modifier)]
|
||||
#![feature(rust_2018_preview)]
|
||||
#![deny(absolute_paths_not_starting_with_crate)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
crate mod foo {
|
||||
crate mod bar {
|
||||
crate mod baz { }
|
||||
crate mod baz1 { }
|
||||
pub(crate) mod foo {
|
||||
pub(crate) mod bar {
|
||||
pub(crate) mod baz { }
|
||||
pub(crate) mod baz1 { }
|
||||
|
||||
crate struct XX;
|
||||
pub(crate) struct XX;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(rust_2018_preview, crate_visibility_modifier)]
|
||||
#![feature(rust_2018_preview)]
|
||||
#![deny(absolute_paths_not_starting_with_crate)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
crate mod foo {
|
||||
crate mod bar {
|
||||
crate mod baz { }
|
||||
crate mod baz1 { }
|
||||
pub(crate) mod foo {
|
||||
pub(crate) mod bar {
|
||||
pub(crate) mod baz { }
|
||||
pub(crate) mod baz1 { }
|
||||
|
||||
crate struct XX;
|
||||
pub(crate) struct XX;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(rust_2018_preview, crate_visibility_modifier)]
|
||||
#![feature(rust_2018_preview)]
|
||||
#![deny(absolute_paths_not_starting_with_crate)]
|
||||
|
||||
use crate::foo::{a, b};
|
||||
@ -10,9 +10,9 @@ use crate::foo::{a, b};
|
||||
//~| this is accepted in the current edition
|
||||
|
||||
mod foo {
|
||||
crate fn a() {}
|
||||
crate fn b() {}
|
||||
crate fn c() {}
|
||||
pub(crate) fn a() {}
|
||||
pub(crate) fn b() {}
|
||||
pub(crate) fn c() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(rust_2018_preview, crate_visibility_modifier)]
|
||||
#![feature(rust_2018_preview)]
|
||||
#![deny(absolute_paths_not_starting_with_crate)]
|
||||
|
||||
use foo::{a, b};
|
||||
@ -10,9 +10,9 @@ use foo::{a, b};
|
||||
//~| this is accepted in the current edition
|
||||
|
||||
mod foo {
|
||||
crate fn a() {}
|
||||
crate fn b() {}
|
||||
crate fn c() {}
|
||||
pub(crate) fn a() {}
|
||||
pub(crate) fn b() {}
|
||||
pub(crate) fn c() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -63,7 +63,7 @@ mod foo {
|
||||
// #2082
|
||||
pub(crate) fn init() {}
|
||||
|
||||
crate fn init() {}
|
||||
pub(crate) fn init() {}
|
||||
|
||||
// #2630
|
||||
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
|
||||
|
@ -24,19 +24,6 @@ pub( crate ) enum WriteState<D> {
|
||||
WriteData(Writer<D>),
|
||||
}
|
||||
|
||||
crate enum WriteState<D> {
|
||||
WriteId {
|
||||
id: U64Writer,
|
||||
size: U64Writer,
|
||||
payload: Option<Writer<D>>,
|
||||
},
|
||||
WriteSize {
|
||||
size: U64Writer,
|
||||
payload: Option<Writer<D>>,
|
||||
},
|
||||
WriteData(Writer<D>),
|
||||
}
|
||||
|
||||
pub(in ::global:: path :: to::some_mod ) enum WriteState<D> {
|
||||
WriteId {
|
||||
id: U64Writer,
|
||||
|
@ -105,7 +105,7 @@ mod foo {
|
||||
// #2082
|
||||
pub(crate) fn init() {}
|
||||
|
||||
crate fn init() {}
|
||||
pub(crate) fn init() {}
|
||||
|
||||
// #2630
|
||||
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
|
||||
|
@ -24,19 +24,6 @@ pub(crate) enum WriteState<D> {
|
||||
WriteData(Writer<D>),
|
||||
}
|
||||
|
||||
crate enum WriteState<D> {
|
||||
WriteId {
|
||||
id: U64Writer,
|
||||
size: U64Writer,
|
||||
payload: Option<Writer<D>>,
|
||||
},
|
||||
WriteSize {
|
||||
size: U64Writer,
|
||||
payload: Option<Writer<D>>,
|
||||
},
|
||||
WriteData(Writer<D>),
|
||||
}
|
||||
|
||||
pub(in global::path::to::some_mod) enum WriteState<D> {
|
||||
WriteId {
|
||||
id: U64Writer,
|
||||
|
Loading…
Reference in New Issue
Block a user