diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 68c59612ccc..5298a560627 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -2007,6 +2007,9 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
}
sidebar.push_str("");
+ } else if let CtorKind::Fn = s.struct_type {
+ sidebar
+ .push_str("
");
}
}
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 2dfbaff1cc9..8f7e8442895 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1176,21 +1176,21 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
_ => None,
})
.peekable();
- if let CtorKind::Fictive = s.struct_type {
+ if let CtorKind::Fictive | CtorKind::Fn = s.struct_type {
if fields.peek().is_some() {
write!(
w,
"\
- Fields{}
",
+ {}{}\
+ ",
+ if let CtorKind::Fictive = s.struct_type { "Fields" } else { "Tuple Fields" },
document_non_exhaustive_header(it)
);
document_non_exhaustive(w, it);
- for (field, ty) in fields {
- let id = cx.derive_id(format!(
- "{}.{}",
- ItemType::StructField,
- field.name.as_ref().unwrap()
- ));
+ for (index, (field, ty)) in fields.enumerate() {
+ let field_name =
+ field.name.map_or_else(|| index.to_string(), |sym| (*sym.as_str()).to_string());
+ let id = cx.derive_id(format!("{}.{}", ItemType::StructField, field_name));
write!(
w,
"\
@@ -1199,7 +1199,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
",
item_type = ItemType::StructField,
id = id,
- name = field.name.as_ref().unwrap(),
+ name = field_name,
ty = ty.print(cx)
);
document(w, cx, field, Some(it));