Skip to content

Exhaustivity checking on match patterns is not defined #798

Description

@alercah

I can't find any mention of exhaustivity checking on the Match expressions page.

Activity

  1. Santino655 commented on Nov 27, 2020

    @Santino655

    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.

  2. ehuss commented on Aug 10, 2024

    @ehuss
    Contributor

    Note: rust-lang/rust#122792 made some recent changes for exhaustiveness.

  3. Nadrieril commented on Aug 10, 2024

    @Nadrieril
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions