Skip to content

Provide type on non-exhaustive pattern matching errors #67259

Description

@Centril

Context & discussion #67026 (comment).

Given e.g.

fn main() {
    match Some(0) {
        None => {}
    }
}

we now get an error:

error[E0004]: non-exhaustive patterns: `Some(_)` not covered
 --> src/main.rs:2:11
  |
2 |     match Some(0) {
  |           ^^^^^^^ pattern `Some(_)` not covered
  |
  = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms

but we should change this into:

error[E0004]: non-exhaustive patterns: `Some(_)` not covered
 --> src/main.rs:2:11
  |
2 |     match Some(0) {
  |           ^^^^^^^ pattern `Some(_)` not covered
  |
  = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
  = note: the matched value is of type `std::option::Option<i32>`

cc @estebank @varkor @Nadrieril

Activity

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

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions