Rollup merge of #49516 - GuillaumeGomez:add-union-field-missing-anchor, r=QuietMisdreavus

Add missing anchor for union type fields

r? @QuietMisdreavus
This commit is contained in:
kennytm 2018-04-04 11:07:13 +02:00 committed by GitHub
commit e0c180362e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2815,10 +2815,15 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
write!(w, "<h2 id='fields' class='fields small-section-header'>
Fields<a href='#fields' class='anchor'></a></h2>")?;
for (field, ty) in fields {
write!(w, "<span id='{shortty}.{name}' class=\"{shortty}\"><code>{name}: {ty}</code>
let name = field.name.as_ref().expect("union field name");
let id = format!("{}.{}", ItemType::StructField, name);
write!(w, "<span id=\"{id}\" class=\"{shortty} small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<span class='invisible'><code>{name}: {ty}</code></span>\
</span>",
id = id,
name = name,
shortty = ItemType::StructField,
name = field.name.as_ref().unwrap(),
ty = ty)?;
if let Some(stability_class) = field.stability_class() {
write!(w, "<span class='stab {stab}'></span>",