@@ -2596,7 +2596,15 @@ fn document_non_exhaustive_header(item: &clean::Item) -> &str {
25962596fn document_non_exhaustive ( w : & mut fmt:: Formatter < ' _ > , item : & clean:: Item ) -> fmt:: Result {
25972597 if item. is_non_exhaustive ( ) {
25982598 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+ }
26002608 } ) ?;
26012609
26022610 if item. is_struct ( ) {
@@ -2609,6 +2617,10 @@ fn document_non_exhaustive(w: &mut fmt::Formatter<'_>, item: &clean::Item) -> fm
26092617 write ! ( w, "Non-exhaustive enums could have additional variants added in future. \
26102618 Therefore, when matching against variants of non-exhaustive enums, an \
26112619 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.") ?;
26122624 } else {
26132625 write ! ( w, "This type will require a wildcard arm in any match statements or \
26142626 constructors.") ?;
@@ -3671,6 +3683,7 @@ fn item_enum(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
36713683 }
36723684 write ! ( w, "</code></span>" ) ?;
36733685 document ( w, cx, variant) ?;
3686+ document_non_exhaustive ( w, variant) ?;
36743687
36753688 use crate :: clean:: { Variant , VariantKind } ;
36763689 if let clean:: VariantItem ( Variant {
0 commit comments