Skip to content

Commit 6de1f2a

Browse files
committed
rustdoc: minor changes suggested by clippy perf lints.
1 parent b42f3aa commit 6de1f2a

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-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::<clean::Attributes>::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

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::cell::RefCell;
2+
use std::fmt::Write;
23
use std::fs::{self, File};
34
use std::io::prelude::*;
45
use std::io::{self, BufReader};
@@ -356,15 +357,14 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
356357

357358
let content = format!(
358359
"<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>()
360+
krates.iter().fold(String::new(), |mut output, s| {
361+
_ = write!(
362+
output,
363+
"<li><a href=\"{trailing_slash}index.html\">{s}</a></li>",
364+
trailing_slash = ensure_trailing_slash(s),
365+
);
366+
output
367+
})
368368
);
369369
let v = layout::render(&shared.layout, &page, "", content, &shared.style_files);
370370
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)