Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid intermediately collecting into vectors
  • Loading branch information
yotamofek committed Jun 19, 2025
commit 569aa26e7bf7f3742fbd6ab3ea3e3c5f9b8d8a75
12 changes: 4 additions & 8 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ impl TraitAliasPart {
},
};

let implementors = imps
let mut implementors = imps
.iter()
.filter_map(|imp| {
// If the trait and implementation are in the same crate, then
Expand All @@ -755,12 +755,12 @@ impl TraitAliasPart {
})
}
})
.collect::<Vec<_>>();
.peekable();

// Only create a js file if we have impls to add to it. If the trait is
// documented locally though we always create the file to avoid dead
// links.
if implementors.is_empty() && !cache.paths.contains_key(&did) {
if implementors.peek().is_none() && !cache.paths.contains_key(&did) {
continue;
}

Expand All @@ -771,11 +771,7 @@ impl TraitAliasPart {
path.push(format!("{remote_item_type}.{}.js", remote_path[remote_path.len() - 1]));

let part = OrderedJson::array_sorted(
implementors
.iter()
.map(OrderedJson::serialize)
.collect::<Result<Vec<_>, _>>()
.unwrap(),
implementors.map(|implementor| OrderedJson::serialize(implementor).unwrap()),
);
path_parts.push(path, OrderedJson::array_unsorted([crate_name_json, &part]));
}
Expand Down