reference
reference copied to clipboard
Exhaustivity checking on match patterns is not defined
I believe that it must be a section talking of exhaustivity stating that a match expression must have either one irrefutable pattern or one or more refutable patterns that contain all the values the scrutinee can be if the type it's not marked with non_exhaustive.
Also note that the last attribute defines well what kind of pattern matching are allowed in a non-exhaustive type but only implicitly what it's accepted outside one of these types. It's particularly unclear with enums saying "When pattern matching on a non-exhaustive enum, matching on a variant does not contribute towards the exhaustiveness of the arms." when it never talks of exhaustiveness before so the reader have to guess that an enum being exhausted refers to all the variants being matched.
Note: https://github.com/rust-lang/rust/pull/122792 made some recent changes for exhaustiveness.
And indeed I could not find anywhere in the reference that talked about exhaustiveness when I made the stabilization PR. The only place that mentioned it a bit was the nomicon.