File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -753,28 +753,34 @@ You tried to use a structure initialization with a non-structure type.
753753Example of erroneous code:
754754
755755```
756- enum Foo { f };
756+ enum Foo { FirstValue };
757757
758- let u = Foo::f { value: 0i32 }; // error: Foo:f isn't a structure!
759- // or even simpler:
760- let u = t { random_field: 0i32 }; //error: t isn't a structure!
758+ let u = Foo::FirstValue { value: 0i32 }; // error: Foo::FirstValue
759+ // isn't a structure!
760+ // or even simpler, if the structure wasn't defined at all:
761+ let u = RandomName { random_field: 0i32 }; // error: RandomName
762+ // isn't a structure!
761763```
762764
763- To fix this error, please declare the structure with the given name
764- first:
765+ To fix this, please check:
766+ * Did you spell it right?
767+ * Did you accidentaly used an enum as a struct?
768+ * Did you accidentaly make an enum when you intended to use a struct?
769+
770+ Here is the previous code with all missing information:
765771
766772```
767773struct Inner {
768774 value: i32
769775}
770776
771777enum Foo {
772- f (Inner)
778+ FirstValue (Inner)
773779}
774780
775781fn main() {
776- let u = Foo::f (Inner { value: 0i32 });
777- // or even simpler:
782+ let u = Foo::FirstValue (Inner { value: 0i32 });
783+
778784 let t = Inner { value: 0i32 };
779785}
780786```
You can’t perform that action at this time.
0 commit comments