about summary refs log tree commit diff
diff options
context:
space:
mode:
authorfee1-dead <ent3rm4n@gmail.com>2023-05-28 06:29:36 +0000
committerGitHub <noreply@github.com>2023-05-28 06:29:36 +0000
commit5a191132bb995558ae20da5db21a3fccb534d5cc (patch)
treeb0e31c4f26d6769cd776226b88f03df4b742f922
parentea1c3e623fbfb47b1a9b1ad1d96c7bec363418a0 (diff)
parenta7329cd66bdd58fce76fd8105911838dae7dc275 (diff)
downloadrust-5a191132bb995558ae20da5db21a3fccb534d5cc.tar.gz
rust-5a191132bb995558ae20da5db21a3fccb534d5cc.zip
Rollup merge of #112005 - sladyn98:item-foreign-types, r=GuillaumeGomez
Migrate `item_foreign_type` to Askama

This PR continues the migration of `print_item.rs` functions to Askama. This piece of work migrates the function `item_foreign_type`

Refers https://github.com/rust-lang/rust/issues/108868
-rw-r--r--src/librustdoc/html/render/print_item.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 62027a3fa19..d2dc47af7ac 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1578,21 +1578,23 @@ fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item,
     write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
 }
 
-fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {
-    wrap_item(w, |w| {
-        w.write_str("extern {\n");
-        render_attributes_in_code(w, it, cx.tcx());
+fn item_foreign_type(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item) {
+    let mut buffer = Buffer::new();
+    wrap_item(&mut buffer, |buffer| {
+        buffer.write_str("extern {\n");
+        render_attributes_in_code(buffer, it, cx.tcx());
         write!(
-            w,
+            buffer,
             "    {}type {};\n}}",
             visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx),
             it.name.unwrap(),
         );
     });
 
-    write!(w, "{}", document(cx, it, None, HeadingOffset::H2));
+    write!(w, "{}{}", buffer.into_inner(), document(cx, it, None, HeadingOffset::H2)).unwrap();
 
     write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
+        .unwrap();
 }
 
 fn item_keyword(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {