Skip to content

Commit

Permalink
Rollup merge of rust-lang#49516 - GuillaumeGomez:add-union-field-miss…
Browse files Browse the repository at this point in the history
…ing-anchor, r=QuietMisdreavus

Add missing anchor for union type fields

r? @QuietMisdreavus
  • Loading branch information
kennytm committed Apr 3, 2018
2 parents c091d07 + adaaeea commit bf80935
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2801,10 +2801,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>",
Expand Down

0 comments on commit bf80935

Please sign in to comment.