Skip to content

non-exhaustive patterns: type ! is non-empty #36011

Closed
@Sh4rK

Description

@Sh4rK

Hi!

I'm trying out feature(never_type) and getting an error on the simplest example possible.
Rustc is rustc 1.13.0-nightly (3c5a0fa45 2016-08-22) on x86_64-pc-windows-msvc.

The code:

#![feature(never_type)]

fn main() {
    let never: !;
    match never {};
}

And the error I get:

error[E0002]: non-exhaustive patterns: type ! is non-empty
 --> src\main.rs:5:5
  |
5 |     match never {};
  |     ^^^^^^^^^^^^^^
  |
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
 --> src\main.rs:5:5
  |
5 |     match never {};
  |     ^^^^^^^^^^^^^^

Which is quite bad, as the point of ! is that it is empty.

If I replace it with an empty enum, it works. (It errors on the uninitialized variable, but that's not the point.)

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