]> git.lizzy.rs Git - rust.git/commitdiff
Add potential cause of the error
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 23 Jun 2015 19:16:24 +0000 (21:16 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 23 Jun 2015 19:47:28 +0000 (21:47 +0200)
src/librustc_typeck/diagnostics.rs

index d660f92db5ee56ed15ca061a8dc7ae794ff9cd03..18341af7ea4b42d0b6e3a7e07f5d38161234cb92 100644 (file)
@@ -753,15 +753,21 @@ fn some_func(x: &mut i32) {
 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 };
 }
 ```