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

Tracking uninhabited types in matches #51076

Closed
Victor-Savu opened this issue May 26, 2018 · 1 comment
Closed

Tracking uninhabited types in matches #51076

Victor-Savu opened this issue May 26, 2018 · 1 comment

Comments

@Victor-Savu
Copy link

Victor-Savu commented May 26, 2018

I think there has been a regression for the treatment of uninhabited types at some point:

#![feature(never_type)]

fn foo() ->  Result<(), !> {
    return Ok(());
}

fn main() {
    match foo() {
        Ok(_) => println!("yay!")
    }
}

now fails with:

error[E0004]: non-exhaustive patterns: `Err(_)` not covered
 --> src/main.rs:7:11
  |
7 |     match foo() {
  |           ^^^^^ pattern `Err(_)` not covered

I will bisect and report back when I find the commit which caused the regression.

Last known to work on:

  • nightly-2018-03-15

Was already failing on:

  • nightly-2018-04-01
@Victor-Savu
Copy link
Author

Turns out the "problem" was introduced in #47630 which attempted to stabilize never_type and leave only this particular case under the exhaustive_patterns feature gate. When that PR was subsequently reverted in #49691, the split in feature gates was not reverted, so now the code above needs both features:

#![feature(never_type)]
#![feature(exhaustive_patterns)]

fn foo() ->  Result<(), !> {
    return Ok(());
}

fn main() {
    match foo() {
        Ok(_) => println!("yay!")
    }
}

I think this issue is not really relevant anymore, but I am afraid that this could be confusing. I look forward to the stabilization of both features, when all of this will go away :)

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

1 participant