Skip to content

Provide type on non-exhaustive pattern matching errors #67259

Closed
@Centril

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

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