@@ -2596,7 +2596,15 @@ fn document_non_exhaustive_header(item: &clean::Item) -> &str {
2596
2596
fn document_non_exhaustive ( w : & mut fmt:: Formatter < ' _ > , item : & clean:: Item ) -> fmt:: Result {
2597
2597
if item. is_non_exhaustive ( ) {
2598
2598
write ! ( w, "<div class='docblock non-exhaustive non-exhaustive-{}'>" , {
2599
- if item. is_struct( ) { "struct" } else if item. is_enum( ) { "enum" } else { "type" }
2599
+ if item. is_struct( ) {
2600
+ "struct"
2601
+ } else if item. is_enum( ) {
2602
+ "enum"
2603
+ } else if item. is_variant( ) {
2604
+ "variant"
2605
+ } else {
2606
+ "type"
2607
+ }
2600
2608
} ) ?;
2601
2609
2602
2610
if item. is_struct ( ) {
@@ -2609,6 +2617,10 @@ fn document_non_exhaustive(w: &mut fmt::Formatter<'_>, item: &clean::Item) -> fm
2609
2617
write ! ( w, "Non-exhaustive enums could have additional variants added in future. \
2610
2618
Therefore, when matching against variants of non-exhaustive enums, an \
2611
2619
extra wildcard arm must be added to account for any future variants.") ?;
2620
+ } else if item. is_variant ( ) {
2621
+ write ! ( w, "Non-exhaustive enum variants could have additional fields added in future. \
2622
+ Therefore, non-exhaustive enum variants cannot be constructed in external \
2623
+ crates and cannot be matched against.") ?;
2612
2624
} else {
2613
2625
write ! ( w, "This type will require a wildcard arm in any match statements or \
2614
2626
constructors.") ?;
@@ -3671,6 +3683,7 @@ fn item_enum(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
3671
3683
}
3672
3684
write ! ( w, "</code></span>" ) ?;
3673
3685
document ( w, cx, variant) ?;
3686
+ document_non_exhaustive ( w, variant) ?;
3674
3687
3675
3688
use crate :: clean:: { Variant , VariantKind } ;
3676
3689
if let clean:: VariantItem ( Variant {
0 commit comments