Remove crate
visibility modifier in libs, tests
This commit is contained in:
parent
49c82f31a8
commit
6970246886
85 changed files with 1059 additions and 1274 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue