1
Fork 0

Rollup merge of #112243 - GuillaumeGomez:rm-unneeded-buffer-creations, r=notriddle

Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directly

With the recent changes, `wrap_item` can now directly take `&mut Write`, which makes some `Buffer` creations unneeded.

r? `@notriddle`
This commit is contained in:
Guillaume Gomez 2023-06-05 17:02:50 +02:00 committed by GitHub
commit aabffef06d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 24 deletions

View file

@ -1040,9 +1040,9 @@ fn render_attributes_in_pre<'a, 'b: 'a>(
// When an attribute is rendered inside a <code> tag, it is formatted using
// a div to produce a newline after it.
fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item, tcx: TyCtxt<'_>) {
for a in it.attributes(tcx, false) {
write!(w, "<div class=\"code-attribute\">{}</div>", a);
fn render_attributes_in_code(w: &mut impl fmt::Write, it: &clean::Item, tcx: TyCtxt<'_>) {
for attr in it.attributes(tcx, false) {
write!(w, "<div class=\"code-attribute\">{attr}</div>").unwrap();
}
}