about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-09-14 15:13:41 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-09-25 16:41:05 +0200
commit33b89a39181b2f5cda8b28320c764ca733f9344a (patch)
treef367bc3bdc15d6f925828320006414e5b0092a5e
parentc9edc02e8320a9e5799d185910ece7d491f524e6 (diff)
downloadrust-33b89a39181b2f5cda8b28320c764ca733f9344a.tar.gz
rust-33b89a39181b2f5cda8b28320c764ca733f9344a.zip
Add long error explanation for E0531
-rw-r--r--src/librustc_resolve/error_codes.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/librustc_resolve/error_codes.rs b/src/librustc_resolve/error_codes.rs
index adbff67cc8d..9a39fcf4223 100644
--- a/src/librustc_resolve/error_codes.rs
+++ b/src/librustc_resolve/error_codes.rs
@@ -1525,6 +1525,51 @@ match r {
 ```
 "##,
 
+E0531: r##"
+An unknown tuple struct/variant has been used.
+
+Erroneous code example:
+
+```compile_fail,E0531
+let Type(x) = Type(12); // error!
+match Bar(12) {
+    Bar(x) => {} // error!
+    _ => {}
+}
+```
+
+In most cases, it's either a forgotten import or a typo. However, let's look at
+how you can have such a type:
+
+```edition2018
+struct Type(u32); // this is a tuple struct
+
+enum Foo {
+    Bar(u32), // this is a tuple variant
+}
+
+use Foo::*; // To use Foo's variant directly, we need to import them in
+            // the scope.
+```
+
+Either way, it should work fine with our previous code:
+
+```edition2018
+struct Type(u32);
+
+enum Foo {
+    Bar(u32),
+}
+use Foo::*;
+
+let Type(x) = Type(12); // ok!
+match Type(12) {
+    Type(x) => {} // ok!
+    _ => {}
+}
+```
+"##,
+
 E0532: r##"
 Pattern arm did not match expected kind.
 
@@ -1675,7 +1720,6 @@ fn const_id<T, const N: T>() -> T { // error: const parameter
 //  E0419, merged into 531
 //  E0420, merged into 532
 //  E0421, merged into 531
-    E0531, // unresolved pattern path kind `name`
 //  E0427, merged into 530
 //  E0467, removed
 //  E0470, removed