]> git.lizzy.rs Git - rust.git/commitdiff
Add Error Explanations for E0163 & E0164
authorWill Speak <lithiumflame@gmail.com>
Sat, 3 Oct 2015 14:42:38 +0000 (15:42 +0100)
committerWill Speak <lithiumflame@gmail.com>
Sat, 3 Oct 2015 14:51:40 +0000 (15:51 +0100)
Addds `--explain` support for E0163 and E0164.

src/librustc_typeck/diagnostics.rs

index 30cb89cf0fde6f50eb358637962e9890c65c0d36..17f43ad277c90eaf01afe284fad5ab791e8ceb06 100644 (file)
@@ -1779,6 +1779,58 @@ fn main<T>() { // error: main function is not allowed to have type parameters
 ```
 "##,
 
+E0163: r##"
+This error means that an attempt was made to match an enum variant as a
+struct type when the variant isn't a struct type:
+
+```
+enum Foo { B(u32) }
+
+fn bar(foo: Foo) -> u32 {
+    match foo {
+        Foo::B{i} => i // error 0163
+    }
+}
+```
+
+Try using `()` instead:
+
+```
+fn bar(foo: Foo) -> u32 {
+    match foo {
+        Foo::B(i) => i
+    }
+}
+```
+"##,
+
+E0164: r##"
+
+This error means that an attempt was made to match a struct type enum
+variant as a non-struct type:
+
+```
+enum Foo { B{ i: u32 } }
+
+fn bar(foo: Foo) -> u32 {
+    match foo {
+        Foo::B(i) => i // error 0164
+    }
+}
+```
+
+Try using `{}` isntead:
+
+```
+fn bar(foo: Foo) -> u32 {
+    match foo {
+        Foo::B{i} => i
+    }
+}
+```
+"##,
+
+
 E0166: r##"
 This error means that the compiler found a return expression in a function
 marked as diverging. A function diverges if it has `!` in the place of the
@@ -3293,8 +3345,6 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 //  E0129,
 //  E0141,
 //  E0159, // use of trait `{}` as struct constructor
-    E0163,
-    E0164,
     E0167,
 //  E0168,
 //  E0173, // manual implementations of unboxed closure traits are experimental