Skip to content

Commit f18f7f1

Browse files
committed
Add some clarifications on what happens when non_exhaustive is added.
1 parent c4ce40c commit f18f7f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/doc/src/reference/semver.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,10 +1121,12 @@ Mitigation strategies:
11211121

11221122
Making items [`#[non_exhaustive]`][non_exhaustive] changes how they may
11231123
be used outside the crate where they are defined:
1124+
11241125
- Non-exhaustive structs and enum variants cannot be constructed
11251126
using [struct literal] syntax, including [functional update syntax].
1126-
- Pattern matching on non-exhaustive enums always requires
1127-
a wildcard (`_`) arm.
1127+
- Pattern matching on non-exhaustive structs requires `..` and
1128+
matching on enums does not count towards exhaustiveness.
1129+
- Casting enum variants to their discriminant with `as` is not allowed.
11281130

11291131
Structs with private fields cannot be constructed using [struct literal] syntax
11301132
regardless of whether [`#[non_exhaustive]`][non_exhaustive] is used.

0 commit comments

Comments
 (0)