about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-06-23 21:16:24 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-06-23 21:47:28 +0200
commit4c2587c1c0865dfa04ce7bebb680c2ceec615f5c (patch)
tree0ac4e7f663e1ca5ce98d00edb9c89d2d4f4f5885
parente52b94e259b7f416ec584164e6803dcbf038b200 (diff)
downloadrust-4c2587c1c0865dfa04ce7bebb680c2ceec615f5c.tar.gz
rust-4c2587c1c0865dfa04ce7bebb680c2ceec615f5c.zip
Add potential cause of the error
-rw-r--r--src/librustc_typeck/diagnostics.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index d660f92db5e..18341af7ea4 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -753,15 +753,21 @@ You tried to use a structure initialization with a non-structure type.
 Example of erroneous code:
 
 ```
-enum Foo { f };
+enum Foo { FirstValue };
 
-let u = Foo::f { value: 0i32 }; // error: Foo:f isn't a structure!
-// or even simpler:
-let u = t { random_field: 0i32 }; //error: t isn't a structure!
+let u = Foo::FirstValue { value: 0i32 }; // error: Foo::FirstValue
+                                         // isn't a structure!
+// or even simpler, if the structure wasn't defined at all:
+let u = RandomName { random_field: 0i32 }; // error: RandomName
+                                           // isn't a structure!
 ```
 
-To fix this error, please declare the structure with the given name
-first:
+To fix this, please check:
+ * Did you spell it right?
+ * Did you accidentaly used an enum as a struct?
+ * Did you accidentaly make an enum when you intended to use a struct?
+
+Here is the previous code with all missing information:
 
 ```
 struct Inner {
@@ -769,12 +775,12 @@ struct Inner {
 }
 
 enum Foo {
-    f(Inner)
+    FirstValue(Inner)
 }
 
 fn main() {
-    let u = Foo::f(Inner { value: 0i32 });
-    // or even simpler:
+    let u = Foo::FirstValue(Inner { value: 0i32 });
+
     let t = Inner { value: 0i32 };
 }
 ```