E0002 - Error codes index
Description: Book listing all Rust error codes

## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# Error code E0002

#### Note: this error code is no longer emitted by the compiler.

This error indicates that an empty match expression is invalid because the type it is matching on is non-empty (there exist values of this type). In safe code it is impossible to create an instance of an empty type, so empty match expressions are almost never desired. This error is typically fixed by adding one or more cases to the match expression.

An example of an empty type is `enum Empty { }`. So, the following will work:

    #![allow(unused)]
    fn main() {
    enum Empty {}

    fn foo(x: Empty) {
        match x {
            // empty
        }
    }
    }

However, this won’t:

    #![allow(unused)]
    fn main() {
    fn foo(x: Option<String>) {
        match x {
            // empty
        }
    }
    }