Skip to content

Commit 7018dd8

Browse files
authored
Rollup merge of rust-lang#49516 - GuillaumeGomez:add-union-field-missing-anchor, r=QuietMisdreavus
Add missing anchor for union type fields r? @QuietMisdreavus
2 parents 8f21773 + adaaeea commit 7018dd8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustdoc/html/render.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -2815,10 +2815,15 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
28152815
write!(w, "<h2 id='fields' class='fields small-section-header'>
28162816
Fields<a href='#fields' class='anchor'></a></h2>")?;
28172817
for (field, ty) in fields {
2818-
write!(w, "<span id='{shortty}.{name}' class=\"{shortty}\"><code>{name}: {ty}</code>
2818+
let name = field.name.as_ref().expect("union field name");
2819+
let id = format!("{}.{}", ItemType::StructField, name);
2820+
write!(w, "<span id=\"{id}\" class=\"{shortty} small-section-header\">\
2821+
<a href=\"#{id}\" class=\"anchor field\"></a>\
2822+
<span class='invisible'><code>{name}: {ty}</code></span>\
28192823
</span>",
2824+
id = id,
2825+
name = name,
28202826
shortty = ItemType::StructField,
2821-
name = field.name.as_ref().unwrap(),
28222827
ty = ty)?;
28232828
if let Some(stability_class) = field.stability_class() {
28242829
write!(w, "<span class='stab {stab}'></span>",

0 commit comments

Comments
 (0)