Skip to content

Commit 8ceb283

Browse files
Rollup merge of #112030 - sladyn98:item-trait-alias, r=GuillaumeGomez
Migrate `item_trait_alias` to Askama This PR migrates `item_trait_alias` to Askama Refers #108868
2 parents ceec225 + 780719b commit 8ceb283

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/librustdoc/html/render/print_item.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,12 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
11011101
);
11021102
}
11031103

1104-
fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TraitAlias) {
1104+
fn item_trait_alias(
1105+
w: &mut impl fmt::Write,
1106+
cx: &mut Context<'_>,
1107+
it: &clean::Item,
1108+
t: &clean::TraitAlias,
1109+
) {
11051110
wrap_item(w, |w| {
11061111
write!(
11071112
w,
@@ -1111,16 +1116,17 @@ fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &
11111116
print_where_clause(&t.generics, cx, 0, Ending::Newline),
11121117
bounds(&t.bounds, true, cx),
11131118
attrs = render_attributes_in_pre(it, "", cx.tcx()),
1114-
);
1119+
)
1120+
.unwrap();
11151121
});
11161122

1117-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2));
1118-
1123+
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
11191124
// Render any items associated directly to this alias, as otherwise they
11201125
// won't be visible anywhere in the docs. It would be nice to also show
11211126
// associated items from the aliased type (see discussion in #32077), but
11221127
// we need #14072 to make sense of the generics.
11231128
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
1129+
.unwrap();
11241130
}
11251131

11261132
fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::OpaqueTy) {
@@ -1673,13 +1679,14 @@ fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool, cx: &Context<'_>)
16731679
bounds
16741680
}
16751681

1676-
fn wrap_item<F>(w: &mut Buffer, f: F)
1682+
fn wrap_item<W, F>(w: &mut W, f: F)
16771683
where
1678-
F: FnOnce(&mut Buffer),
1684+
W: fmt::Write,
1685+
F: FnOnce(&mut W),
16791686
{
1680-
w.write_str(r#"<pre class="rust item-decl"><code>"#);
1687+
write!(w, r#"<pre class="rust item-decl"><code>"#).unwrap();
16811688
f(w);
1682-
w.write_str("</code></pre>");
1689+
write!(w, "</code></pre>").unwrap();
16831690
}
16841691

16851692
#[derive(PartialEq, Eq)]

0 commit comments

Comments
 (0)