@@ -1037,8 +1037,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1037
1037
write ! ( w, "<div class=\" sub-variant\" id=\" {id}\" >" , id = variant_id) ;
1038
1038
write ! (
1039
1039
w,
1040
- "<h3>Fields of <b>{name}</b></h3><div>" ,
1041
- name = variant. name. as_ref( ) . unwrap( )
1040
+ "<h3>{extra}Fields of <b>{name}</b></h3><div>" ,
1041
+ extra = if s. struct_type == CtorKind :: Fn { "Tuple " } else { "" } ,
1042
+ name = variant. name. as_ref( ) . unwrap( ) ,
1042
1043
) ;
1043
1044
for field in & s. fields {
1044
1045
use crate :: clean:: StructFieldItem ;
@@ -1176,21 +1177,21 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
1176
1177
_ => None ,
1177
1178
} )
1178
1179
. peekable ( ) ;
1179
- if let CtorKind :: Fictive = s. struct_type {
1180
+ if let CtorKind :: Fictive | CtorKind :: Fn = s. struct_type {
1180
1181
if fields. peek ( ) . is_some ( ) {
1181
1182
write ! (
1182
1183
w,
1183
1184
"<h2 id=\" fields\" class=\" fields small-section-header\" >\
1184
- Fields{}<a href=\" #fields\" class=\" anchor\" ></a></h2>",
1185
+ {}{}<a href=\" #fields\" class=\" anchor\" ></a>\
1186
+ </h2>",
1187
+ if let CtorKind :: Fictive = s. struct_type { "Fields" } else { "Tuple Fields" } ,
1185
1188
document_non_exhaustive_header( it)
1186
1189
) ;
1187
1190
document_non_exhaustive ( w, it) ;
1188
- for ( field, ty) in fields {
1189
- let id = cx. derive_id ( format ! (
1190
- "{}.{}" ,
1191
- ItemType :: StructField ,
1192
- field. name. as_ref( ) . unwrap( )
1193
- ) ) ;
1191
+ for ( index, ( field, ty) ) in fields. enumerate ( ) {
1192
+ let field_name =
1193
+ field. name . map_or_else ( || index. to_string ( ) , |sym| ( * sym. as_str ( ) ) . to_string ( ) ) ;
1194
+ let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: StructField , field_name) ) ;
1194
1195
write ! (
1195
1196
w,
1196
1197
"<span id=\" {id}\" class=\" {item_type} small-section-header\" >\
@@ -1199,7 +1200,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
1199
1200
</span>",
1200
1201
item_type = ItemType :: StructField ,
1201
1202
id = id,
1202
- name = field . name . as_ref ( ) . unwrap ( ) ,
1203
+ name = field_name ,
1203
1204
ty = ty. print( cx)
1204
1205
) ;
1205
1206
document ( w, cx, field, Some ( it) ) ;
@@ -1507,7 +1508,10 @@ fn render_struct(
1507
1508
if let Some ( g) = g {
1508
1509
write ! ( w, "{}" , print_where_clause( g, cx, 0 , false ) , )
1509
1510
}
1510
- w. write_str ( ";" ) ;
1511
+ // We only want a ";" when we are displaying a tuple struct, not a variant tuple struct.
1512
+ if structhead {
1513
+ w. write_str ( ";" ) ;
1514
+ }
1511
1515
}
1512
1516
CtorKind :: Const => {
1513
1517
// Needed for PhantomData.
0 commit comments