Skip to content

Commit 1e766bf

Browse files
authored
Rollup merge of #111927 - sladyn98:item-static, r=GuillaumeGomez
Migrate `item_static` to Askama This pull request addresses the type signature of the item_static function in our codebase. Previously, this function accepted a mutable reference to a Buffer for writing output. The current changes modify this to instead accept a mutable reference to any type that implements the Write trait. Referes #108868
2 parents 51cf1b6 + aa67ae2 commit 1e766bf

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustdoc/html/render/print_item.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1541,19 +1541,23 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
15411541
write!(w, "{}", document_type_layout(cx, def_id));
15421542
}
15431543

1544-
fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
1545-
wrap_item(w, |w| {
1546-
render_attributes_in_code(w, it, cx.tcx());
1544+
fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
1545+
let mut buffer = Buffer::new();
1546+
wrap_item(&mut buffer, |buffer| {
1547+
render_attributes_in_code(buffer, it, cx.tcx());
15471548
write!(
1548-
w,
1549+
buffer,
15491550
"{vis}static {mutability}{name}: {typ}",
15501551
vis = visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx),
15511552
mutability = s.mutability.print_with_space(),
15521553
name = it.name.unwrap(),
15531554
typ = s.type_.print(cx)
15541555
);
15551556
});
1556-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2))
1557+
1558+
write!(w, "{}", buffer.into_inner()).unwrap();
1559+
1560+
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
15571561
}
15581562

15591563
fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {

0 commit comments

Comments
 (0)