Skip to content

Commit bd0cb1e

Browse files
committed
Mark the "#[default]" variant for enums
1 parent 94ba57c commit bd0cb1e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/librustdoc/html/render/print_item.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,9 @@ fn item_variants(
16181618
if let clean::VariantKind::Tuple(ref s) = variant_data.kind {
16191619
write!(w, "({})", print_tuple_struct_fields(cx, s));
16201620
}
1621+
if variant.attrs.other_attrs.iter().any(|a| a.has_name(kw::Default)) {
1622+
w.write_str(" <span class=\"stab default\">Default</span>");
1623+
}
16211624
w.write_str("</h3></section>");
16221625

16231626
let heading_and_fields = match &variant_data.kind {

tests/rustdoc/attributes.rs

+8
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ pub extern "C" fn g() {}
1111
// @has foo/struct.Repr.html '//pre[@class="rust item-decl"]' '#[repr(C, align(8))]'
1212
#[repr(C, align(8))]
1313
pub struct Repr;
14+
15+
// @has foo/enum.Enum.html '//section[@id="variant.Foo"]' 'Default'
16+
#[derive(Default)]
17+
pub enum Enum {
18+
#[default]
19+
Foo,
20+
Bar,
21+
}

0 commit comments

Comments
 (0)