Skip to content
Closed
16 changes: 11 additions & 5 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ fn assoc_method(
write!(w, "{}", render_attributes_in_pre(meth, indent_str, cx));
(4, indent_str, Ending::NoNewline)
} else {
render_attributes_in_code(w, meth, cx);
write!(w, "{}", render_attributes_in_code(meth, tcx));
(0, "", Ending::Newline)
};
w.reserve(header_len + "<a href=\"\" class=\"fn\">{".len() + "</a>".len());
Expand Down Expand Up @@ -1075,10 +1075,16 @@ fn render_attributes_in_pre<'a, 'tcx: 'a>(

// When an attribute is rendered inside a <code> tag, it is formatted using
// a div to produce a newline after it.
fn render_attributes_in_code(w: &mut impl fmt::Write, it: &clean::Item, cx: &Context<'_>) {
for attr in it.attributes(cx.tcx(), cx.cache(), false) {
write!(w, "<div class=\"code-attribute\">{attr}</div>").unwrap();
}
fn render_attributes_in_code<'a, 'tcx>(
it: &'a clean::Item,
tcx: TyCtxt<'tcx>,
) -> impl fmt::Display + Captures<'a> + Captures<'tcx> {
display_fn(move |f| {
for a in it.attributes(tcx, false) {
write!(f, "<div class=\"code-attribute\">{}</div>", a)?;
}
Ok(())
})
}

#[derive(Copy, Clone)]
Expand Down
Loading