]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0002.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0002.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 This error indicates that an empty match expression is invalid because the type
4 it is matching on is non-empty (there exist values of this type). In safe code
5 it is impossible to create an instance of an empty type, so empty match
6 expressions are almost never desired. This error is typically fixed by adding
7 one or more cases to the match expression.
8
9 An example of an empty type is `enum Empty { }`. So, the following will work:
10
11 ```
12 enum Empty {}
13
14 fn foo(x: Empty) {
15     match x {
16         // empty
17     }
18 }
19 ```
20
21 However, this won't:
22
23 ```compile_fail
24 fn foo(x: Option<String>) {
25     match x {
26         // empty
27     }
28 }
29 ```