diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 6abc3b82e4a5..06cb9269cc87 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -538,7 +538,7 @@ fn document(
}
fmt::from_fn(move |f| {
- document_item_info(cx, item, parent).render_into(f).unwrap();
+ document_item_info(cx, item, parent).render_into(f)?;
if parent.is_none() {
write!(f, "{}", document_full_collapsible(item, cx, heading_offset))
} else {
@@ -582,7 +582,7 @@ fn document_short(
show_def_docs: bool,
) -> impl fmt::Display {
fmt::from_fn(move |f| {
- document_item_info(cx, item, Some(parent)).render_into(f).unwrap();
+ document_item_info(cx, item, Some(parent)).render_into(f)?;
if !show_def_docs {
return Ok(());
}