Skip to content

match &never {} is an error #50642

@stepancheg

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 {
    };
}

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