Skip to content

Commit 5a19113

Browse files
authored
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 #108868
2 parents ea1c3e6 + a7329cd commit 5a19113

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/librustdoc/html/render/print_item.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1578,21 +1578,23 @@ fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item,
15781578
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
15791579
}
15801580

1581-
fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {
1582-
wrap_item(w, |w| {
1583-
w.write_str("extern {\n");
1584-
render_attributes_in_code(w, it, cx.tcx());
1581+
fn item_foreign_type(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item) {
1582+
let mut buffer = Buffer::new();
1583+
wrap_item(&mut buffer, |buffer| {
1584+
buffer.write_str("extern {\n");
1585+
render_attributes_in_code(buffer, it, cx.tcx());
15851586
write!(
1586-
w,
1587+
buffer,
15871588
" {}type {};\n}}",
15881589
visibility_print_with_space(it.visibility(cx.tcx()), it.item_id, cx),
15891590
it.name.unwrap(),
15901591
);
15911592
});
15921593

1593-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2));
1594+
write!(w, "{}{}", buffer.into_inner(), document(cx, it, None, HeadingOffset::H2)).unwrap();
15941595

15951596
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
1597+
.unwrap();
15961598
}
15971599

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

0 commit comments

Comments
 (0)