Skip to content

match &never {} is an error #50642

Closed
Closed

Description

@stepancheg
enum Never {
}

fn foo(n: Never) {
    match &n {
    };
}

result is

error[E0004]: non-exhaustive patterns: type &Never is non-empty
 --> src/main.rs:5:11
  |
5 |     match &n {
  |           ^^
  |
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
 --> src/main.rs:5:11
  |
5 |     match &n {
  |           ^^

Rust 1.27.

I'm not 100% sure, but I guess this code should be valid, because following is valid:

enum Never {
}

fn foo(n: Never) {
    match n {
    };
}

Activity

  1. scottmcm commented on May 11, 2018

    @scottmcm
    Member

    Personally I agree, but the "Fix the handling of uninhabited types in pattern matching" RFC was postponed: rust-lang/rfcs#1872

  2. stepancheg commented on May 11, 2018

    @stepancheg
    ContributorAuthor

    OK, it is a know issue. Thank you @scottmcm!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions