summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0002.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0002.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0002.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0002.md b/compiler/rustc_error_codes/src/error_codes/E0002.md
new file mode 100644
index 000000000..5cb59da10
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0002.md
@@ -0,0 +1,29 @@
+#### 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:
+
+```
+enum Empty {}
+
+fn foo(x: Empty) {
+ match x {
+ // empty
+ }
+}
+```
+
+However, this won't:
+
+```compile_fail
+fn foo(x: Option<String>) {
+ match x {
+ // empty
+ }
+}
+```