Skip to content

Tracking uninhabited types in matches #51076

Closed

Description

@Victor-Savu

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

Activity

  1. Victor-Savu commented on May 26, 2018

    @Victor-Savu
    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

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