Skip to content

Commit e8cf29b

Browse files
committed
rustdoc: minor changes suggested by clippy perf lints.
1 parent 1b3733e commit e8cf29b

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ fn build_module_items(
599599
let prim_ty = clean::PrimitiveType::from(p);
600600
items.push(clean::Item {
601601
name: None,
602-
attrs: Box::new(clean::Attributes::default()),
602+
attrs: Box::default(),
603603
// We can use the item's `DefId` directly since the only information ever used
604604
// from it is `DefId.krate`.
605605
item_id: ItemId::DefId(did),

src/librustdoc/clean/types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,7 @@ impl WherePredicate {
13271327
pub(crate) enum GenericParamDefKind {
13281328
Lifetime { outlives: ThinVec<Lifetime> },
13291329
Type { did: DefId, bounds: ThinVec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
1330+
// Option<Box<String>> makes this type smaller than `Option<String>` would.
13301331
Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
13311332
}
13321333

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
588588
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
589589
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
590590
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
591-
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit("/").filter(|c| !c.is_empty()).next().unwrap());
591+
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').filter(|c| !c.is_empty()).next().unwrap());
592592

593593
/// Render a sequence of macro arms in a format suitable for displaying to the user
594594
/// as part of an item declaration.

src/librustdoc/html/render/write_shared.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,12 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
356356

357357
let content = format!(
358358
"<h1>List of all crates</h1><ul class=\"all-items\">{}</ul>",
359-
krates
360-
.iter()
361-
.map(|s| {
362-
format!(
363-
"<li><a href=\"{trailing_slash}index.html\">{s}</a></li>",
364-
trailing_slash = ensure_trailing_slash(s),
365-
)
366-
})
367-
.collect::<String>()
359+
krates.iter().format_with("", |k, f| {
360+
f(&format_args!(
361+
"<li><a href=\"{trailing_slash}index.html\">{k}</a></li>",
362+
trailing_slash = ensure_trailing_slash(k),
363+
))
364+
})
368365
);
369366
let v = layout::render(&shared.layout, &page, "", content, &shared.style_files);
370367
shared.fs.write(dst, v)?;

src/librustdoc/passes/lint/redundant_explicit_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn check_redundant_explicit_link<'md>(
8787
let link_data = collect_link_data(&mut offset_iter);
8888

8989
if let Some(resolvable_link) = link_data.resolvable_link.as_ref() {
90-
if &link_data.display_link.replace("`", "") != resolvable_link {
90+
if &link_data.display_link.replace('`', "") != resolvable_link {
9191
// Skips if display link does not match to actual
9292
// resolvable link, usually happens if display link
9393
// has several segments, e.g.

0 commit comments

Comments
 (0)