From 26fa3e40012d1388f5044c43f54520438ed5c7ff Mon Sep 17 00:00:00 2001 From: Omid Rad Date: Tue, 5 Sep 2023 19:37:28 +0200 Subject: [PATCH] Add a `default` flag for enum documentation fixes #115438 --- src/librustdoc/html/render/print_item.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index cb78f903462c1..5d7c3d3af0305 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1356,6 +1356,9 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: toggle_open(&mut w, format_args!("{count_variants} variants")); } for v in e.variants() { + if v.is_default() { + w.write_str(" #[default]"); + } w.write_str(" "); let name = v.name.unwrap(); match *v.kind { @@ -1419,6 +1422,9 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: if let clean::VariantKind::Tuple(ref s) = variant_data.kind { write!(w, "({})", print_tuple_struct_fields(cx, s)); } + if variant.is_default() { + w.write_str(" (Default)"); + } w.write_str(""); let heading_and_fields = match &variant_data.kind {