Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match &never {} is an error #50642

Closed
stepancheg opened this issue May 11, 2018 · 2 comments
Closed

match &never {} is an error #50642

stepancheg opened this issue May 11, 2018 · 2 comments

Comments

@stepancheg
Copy link
Contributor

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 {
    };
}
@scottmcm
Copy link
Member

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

@stepancheg
Copy link
Contributor Author

stepancheg commented May 11, 2018

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants