about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-03-30 16:10:05 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-03-30 16:10:16 +0200
commitadaaeeaee341d9cc4472afc8287704dd5cea521e (patch)
tree84eb5a94ab6e5dcbc2b9d1b1ee9536ed37486fc0 /src
parent696076144d4d904cc99c02f85cf46bbe52404657 (diff)
downloadrust-adaaeeaee341d9cc4472afc8287704dd5cea521e.tar.gz
rust-adaaeeaee341d9cc4472afc8287704dd5cea521e.zip
Add missing anchor for union type fields
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/render.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ff6cc56e5b4..38696bb7149 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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>",