Skip to content

Commit 658bd78

Browse files
authored
Rollup merge of rust-lang#112031 - sladyn98:migrate-proc-macro, r=GuillaumeGomez
Migrate `item_proc_macro` to Askama This PR migrates `item_proc_macro` to Askama Refers rust-lang#108868
2 parents e898e7c + 5c780d9 commit 658bd78

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/librustdoc/html/render/print_item.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -1420,30 +1420,36 @@ fn item_macro(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
14201420
write!(w, "{}", document(cx, it, None, HeadingOffset::H2))
14211421
}
14221422

1423-
fn item_proc_macro(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, m: &clean::ProcMacro) {
1424-
wrap_item(w, |w| {
1423+
fn item_proc_macro(
1424+
w: &mut impl fmt::Write,
1425+
cx: &mut Context<'_>,
1426+
it: &clean::Item,
1427+
m: &clean::ProcMacro,
1428+
) {
1429+
let mut buffer = Buffer::new();
1430+
wrap_item(&mut buffer, |buffer| {
14251431
let name = it.name.expect("proc-macros always have names");
14261432
match m.kind {
14271433
MacroKind::Bang => {
1428-
write!(w, "{}!() {{ /* proc-macro */ }}", name);
1434+
write!(buffer, "{}!() {{ /* proc-macro */ }}", name);
14291435
}
14301436
MacroKind::Attr => {
1431-
write!(w, "#[{}]", name);
1437+
write!(buffer, "#[{}]", name);
14321438
}
14331439
MacroKind::Derive => {
1434-
write!(w, "#[derive({})]", name);
1440+
write!(buffer, "#[derive({})]", name);
14351441
if !m.helpers.is_empty() {
1436-
w.push_str("\n{\n");
1437-
w.push_str(" // Attributes available to this derive:\n");
1442+
buffer.push_str("\n{\n");
1443+
buffer.push_str(" // Attributes available to this derive:\n");
14381444
for attr in &m.helpers {
1439-
writeln!(w, " #[{}]", attr);
1445+
writeln!(buffer, " #[{}]", attr);
14401446
}
1441-
w.push_str("}\n");
1447+
buffer.push_str("}\n");
14421448
}
14431449
}
14441450
}
14451451
});
1446-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2))
1452+
write!(w, "{}{}", buffer.into_inner(), document(cx, it, None, HeadingOffset::H2)).unwrap();
14471453
}
14481454

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

0 commit comments

Comments
 (0)