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 https://github.com/rust-lang/rust/issues/108868
This commit is contained in:
Matthias Krüger 2023-05-27 00:23:58 +02:00 committed by GitHub
commit 1e766bfd2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1541,11 +1541,12 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
write!(w, "{}", document_type_layout(cx, def_id));
}
fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
wrap_item(w, |w| {
render_attributes_in_code(w, it, cx.tcx());
fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
let mut buffer = Buffer::new();
wrap_item(&mut buffer, |buffer| {
render_attributes_in_code(buffer, it, cx.tcx());
write!(
w,
buffer,
"{vis}static {mutability}{name}: {typ}",
vis = visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx),
mutability = s.mutability.print_with_space(),
@ -1553,7 +1554,10 @@ fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
typ = s.type_.print(cx)
);
});
write!(w, "{}", document(cx, it, None, HeadingOffset::H2))
write!(w, "{}", buffer.into_inner()).unwrap();
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
}
fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {