]> git.lizzy.rs Git - rust.git/commitdiff
Add E0532 error explanation
authorAndreas Sommer <andreas.sommer87@googlemail.com>
Sat, 29 Oct 2016 23:03:16 +0000 (01:03 +0200)
committerAndreas Sommer <andreas.sommer87@googlemail.com>
Mon, 31 Oct 2016 00:53:23 +0000 (01:53 +0100)
src/librustc_resolve/diagnostics.rs

index 1fb5db05dd5088e0b7c8f55942f5a3b496537024..5eb269030a004fa2b1ce8b2d43ee9809cf027321 100644 (file)
@@ -1461,6 +1461,47 @@ macro_rules! drink {
 ```
 "##,
 
+E0532: r##"
+Pattern arm did not match expected kind.
+
+Erroneous code example:
+
+```compile_fail,E0532
+enum State {
+    Succeeded,
+    Failed(String),
+}
+
+fn print_on_failure(state: &State) {
+    match *state {
+        // error: expected unit struct/variant or constant, found tuple
+        //        variant `State::Failed`
+        State::Failed => println!("Failed"),
+        _ => ()
+    }
+}
+```
+
+To fix this error, ensure the match arm kind is the same as the expression
+matched.
+
+Fixed example:
+
+```
+enum State {
+    Succeeded,
+    Failed(String),
+}
+
+fn print_on_failure(state: &State) {
+    match *state {
+        State::Failed(ref msg) => println!("Failed with {}", msg),
+        _ => ()
+    }
+}
+```
+"##,
+
 }
 
 register_diagnostics! {
@@ -1480,6 +1521,5 @@ macro_rules! drink {
 //  E0421, merged into 531
 //  E0422, merged into 531/532
     E0531, // unresolved pattern path kind `name`
-    E0532, // expected pattern path kind, found another pattern path kind
 //  E0427, merged into 530
 }