diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 88e90dfd2d32..e64d339fabca 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -705,13 +705,13 @@ fn resolved_path(
f,
"{path}::{anchor}",
path = join_with_double_colon(&fqp[..fqp.len() - 1]),
- anchor = anchor(did, *fqp.last().unwrap(), cx)
+ anchor = print_anchor(did, *fqp.last().unwrap(), cx)
)
} else {
write!(f, "{}", last.name)
}
} else {
- write!(f, "{}", anchor(did, last.name, cx))
+ write!(f, "{}", print_anchor(did, last.name, cx))
}
});
write!(w, "{path}{args}", args = last.args.print(cx))?;
@@ -797,7 +797,7 @@ fn primitive_link_fragment(
Ok(())
}
-fn tybounds(
+fn print_tybounds(
bounds: &[clean::PolyTrait],
lt: &Option,
cx: &Context<'_>,
@@ -829,7 +829,7 @@ fn print_higher_ranked_params_with_space(
})
}
-pub(crate) fn anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display {
+pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display {
fmt::from_fn(move |f| {
let parts = href(did, cx);
if let Ok((url, short_ty, fqp)) = parts {
@@ -863,7 +863,7 @@ fn fmt_type(
}
clean::DynTrait(bounds, lt) => {
f.write_str("dyn ")?;
- tybounds(bounds, lt, cx).fmt(f)
+ print_tybounds(bounds, lt, cx).fmt(f)
}
clean::Infer => write!(f, "_"),
clean::Primitive(clean::PrimitiveType::Never) => {
@@ -1128,7 +1128,7 @@ impl clean::Impl {
self.print_type(inner_type, f, use_absolute, cx)?;
write!(f, ">")?;
} else {
- write!(f, "{}<", anchor(ty.def_id(), last, cx))?;
+ write!(f, "{}<", print_anchor(ty.def_id(), last, cx))?;
self.print_type(inner_type, f, use_absolute, cx)?;
write!(f, ">")?;
}
@@ -1203,7 +1203,7 @@ impl clean::Impl {
&& self.kind.is_fake_variadic()
{
let ty = generics[0];
- let wrapper = anchor(path.def_id(), path.last(), cx);
+ let wrapper = print_anchor(path.def_id(), path.last(), cx);
if f.alternate() {
write!(f, "{wrapper:#}<")?;
} else {
@@ -1416,7 +1416,7 @@ pub(crate) fn visibility_print_with_space(item: &clean::Item, cx: &Context<'_>)
debug!("path={path:?}");
// modified from `resolved_path()` to work with `DefPathData`
let last_name = path.data.last().unwrap().data.get_opt_name().unwrap();
- let anchor = anchor(vis_did, last_name, cx);
+ let anchor = print_anchor(vis_did, last_name, cx);
let mut s = "pub(in ".to_owned();
for seg in &path.data[..path.data.len() - 1] {
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 1f7201b8ca8b..5984dcd74caf 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -14,7 +14,7 @@ use rustc_span::edition::Edition;
use rustc_span::{FileName, Symbol, sym};
use tracing::info;
-use super::print_item::{full_path, item_path, print_item};
+use super::print_item::{full_path, print_item, print_item_path};
use super::sidebar::{ModuleLike, Sidebar, print_sidebar, sidebar_module_like};
use super::{AllTypes, LinkFromSrc, StylePath, collect_spans_and_sources, scrape_examples_help};
use crate::clean::types::ExternalLocation;
@@ -266,7 +266,7 @@ impl<'tcx> Context<'tcx> {
for name in &names[..names.len() - 1] {
write!(f, "{name}/")?;
}
- write!(f, "{}", item_path(ty, names.last().unwrap().as_str()))
+ write!(f, "{}", print_item_path(ty, names.last().unwrap().as_str()))
});
match self.shared.redirections {
Some(ref redirections) => {
@@ -278,7 +278,7 @@ impl<'tcx> Context<'tcx> {
let _ = write!(
current_path,
"{}",
- item_path(ty, names.last().unwrap().as_str())
+ print_item_path(ty, names.last().unwrap().as_str())
);
redirections.borrow_mut().insert(current_path, path.to_string());
}
@@ -847,7 +847,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
if !buf.is_empty() {
let name = item.name.as_ref().unwrap();
let item_type = item.type_();
- let file_name = item_path(item_type, name.as_str()).to_string();
+ let file_name = print_item_path(item_type, name.as_str()).to_string();
self.shared.ensure_dir(&self.dst)?;
let joint_dst = self.dst.join(&file_name);
self.shared.fs.write(joint_dst, buf)?;
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 39a631b637bd..32f535e8e8cc 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -413,7 +413,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
match myitem.kind {
clean::ExternCrateItem { ref src } => {
- use crate::html::format::anchor;
+ use crate::html::format::print_anchor;
match *src {
Some(src) => {
@@ -421,7 +421,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
w,
"{}extern crate {} as {};",
visibility_print_with_space(myitem, cx),
- anchor(myitem.item_id.expect_def_id(), src, cx),
+ print_anchor(myitem.item_id.expect_def_id(), src, cx),
EscapeBodyTextWithWbr(myitem.name.unwrap().as_str())
)?;
}
@@ -430,7 +430,11 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
w,
"{}extern crate {};",
visibility_print_with_space(myitem, cx),
- anchor(myitem.item_id.expect_def_id(), myitem.name.unwrap(), cx)
+ print_anchor(
+ myitem.item_id.expect_def_id(),
+ myitem.name.unwrap(),
+ cx
+ )
)?;
}
}
@@ -439,7 +443,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
clean::ImportItem(ref import) => {
let stab_tags = import.source.did.map_or_else(String::new, |import_def_id| {
- extra_info_tags(tcx, myitem, item, Some(import_def_id)).to_string()
+ print_extra_info_tags(tcx, myitem, item, Some(import_def_id)).to_string()
});
let id = match import.kind {
@@ -497,7 +501,9 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
write!(
w,
"\
- {name}\
+ \
+ {name}\
+ \
{visibility_and_hidden}\
{unsafety_flag}\
{stab_tags}\
@@ -505,11 +511,12 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
{docs_before}{docs}{docs_after}",
name = EscapeBodyTextWithWbr(myitem.name.unwrap().as_str()),
visibility_and_hidden = visibility_and_hidden,
- stab_tags = extra_info_tags(tcx, myitem, item, None),
+ stab_tags = print_extra_info_tags(tcx, myitem, item, None),
class = myitem.type_(),
unsafety_flag = unsafety_flag,
- href = item_path(myitem.type_(), myitem.name.unwrap().as_str()),
- title = format_args!("{} {}", myitem.type_(), full_path(cx, myitem)),
+ href = print_item_path(myitem.type_(), myitem.name.unwrap().as_str()),
+ title1 = myitem.type_(),
+ title2 = full_path(cx, myitem),
)?;
}
}
@@ -524,7 +531,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
/// at the module level.
-fn extra_info_tags(
+fn print_extra_info_tags(
tcx: TyCtxt<'_>,
item: &clean::Item,
parent: &clean::Item,
@@ -639,7 +646,7 @@ fn item_function(cx: &Context<'_>, it: &clean::Item, f: &clean::Function) -> imp
fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt::Display {
fmt::from_fn(|w| {
let tcx = cx.tcx();
- let bounds = bounds(&t.bounds, false, cx);
+ let bounds = print_bounds(&t.bounds, false, cx);
let required_types =
t.items.iter().filter(|m| m.is_required_associated_type()).collect::>();
let provided_types = t.items.iter().filter(|m| m.is_associated_type()).collect::>();
@@ -1236,7 +1243,7 @@ fn item_trait_alias(
attrs = render_attributes_in_pre(it, "", cx),
name = it.name.unwrap(),
generics = t.generics.print(cx),
- bounds = bounds(&t.bounds, true, cx),
+ bounds = print_bounds(&t.bounds, true, cx),
where_clause =
print_where_clause(&t.generics, cx, 0, Ending::NoNewline).maybe_display(),
)
@@ -2185,14 +2192,18 @@ pub(super) fn full_path(cx: &Context<'_>, item: &clean::Item) -> String {
s
}
-pub(super) fn item_path(ty: ItemType, name: &str) -> impl Display {
+pub(super) fn print_item_path(ty: ItemType, name: &str) -> impl Display {
fmt::from_fn(move |f| match ty {
ItemType::Module => write!(f, "{}index.html", ensure_trailing_slash(name)),
_ => write!(f, "{ty}.{name}.html"),
})
}
-fn bounds(bounds: &[clean::GenericBound], trait_alias: bool, cx: &Context<'_>) -> impl Display {
+fn print_bounds(
+ bounds: &[clean::GenericBound],
+ trait_alias: bool,
+ cx: &Context<'_>,
+) -> impl Display {
(!bounds.is_empty())
.then_some(fmt::from_fn(move |f| {
let has_lots_of_bounds = bounds.len() > 2;