@@ -2265,22 +2265,35 @@ fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item)
2265
2265
2266
2266
fn document_non_exhaustive ( w : & mut fmt:: Formatter , item : & clean:: Item ) -> fmt:: Result {
2267
2267
if item. non_exhaustive {
2268
- let name = item. type_ ( ) ;
2269
- write ! ( w, r##"
2270
- <div class='non-exhaustive'>
2271
- <div class='stab non-exhaustive'>
2272
- <details>
2273
- <summary>
2274
- <span class=microscope>🔬</span>
2275
- This {} is marked as non exhaustive.
2276
- </summary>
2277
- <p>
2278
- This {} will require a wildcard arm in any match statements or constructors.
2279
- </p>
2280
- </details>
2281
- </div>
2282
- </div>
2283
- "## , name, name) ?;
2268
+ write ! ( w, "<div class='non-exhaustive'><div class='stab non-exhaustive'>" ) ?;
2269
+ write ! ( w, "<details><summary><span class=microscope>🔬</span>" ) ?;
2270
+
2271
+ if item. is_struct ( ) {
2272
+ write ! ( w, "This struct is marked as non exhaustive." ) ?;
2273
+ } else if item. is_enum ( ) {
2274
+ write ! ( w, "This enum is marked as non exhaustive." ) ?;
2275
+ } else {
2276
+ write ! ( w, "This type is marked as non exhaustive." ) ?;
2277
+ }
2278
+
2279
+ write ! ( w, "</summary><p>" ) ?;
2280
+
2281
+ if item. is_struct ( ) {
2282
+ write ! ( w, "This struct is marked as non-exhaustive as additional fields may be \
2283
+ added in the future. This means that this struct cannot be constructed in \
2284
+ external crates using the traditional <code>Struct {{ .. }}</code> syntax;
2285
+ cannot be matched against without a wildcard <code>..</code>; and \
2286
+ functional-record-updates do not work on this struct.") ?;
2287
+ } else if item. is_enum ( ) {
2288
+ write ! ( w, "This enum is marked as non-exhaustive, and additional variants may be \
2289
+ added in the future. When matching over values of this type, an extra \
2290
+ <code>_</code> arm must be added to account for future extensions.") ?;
2291
+ } else {
2292
+ write ! ( w, "This type will require a wildcard arm in any match statements or \
2293
+ constructors.") ?;
2294
+ }
2295
+
2296
+ write ! ( w, "</p></details></div></div>" ) ?;
2284
2297
}
2285
2298
2286
2299
Ok ( ( ) )
0 commit comments