Skip to content

Commit

Permalink
Add some clarifications on what happens when non_exhaustive is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed May 1, 2023
1 parent c4ce40c commit f18f7f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/doc/src/reference/semver.md
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,12 @@ Mitigation strategies:

Making items [`#[non_exhaustive]`][non_exhaustive] changes how they may
be used outside the crate where they are defined:

- Non-exhaustive structs and enum variants cannot be constructed
using [struct literal] syntax, including [functional update syntax].
- Pattern matching on non-exhaustive enums always requires
a wildcard (`_`) arm.
- Pattern matching on non-exhaustive structs requires `..` and
matching on enums does not count towards exhaustiveness.
- Casting enum variants to their discriminant with `as` is not allowed.

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

0 comments on commit f18f7f1

Please sign in to comment.