Skip to content

Commit 1766301

Browse files
---
yaml --- r: 223281 b: refs/heads/beta c: 4c2587c h: refs/heads/master i: 223279: e843349 v: v3
1 parent c6d0d53 commit 1766301

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: e52b94e259b7f416ec584164e6803dcbf038b200
26+
refs/heads/beta: 4c2587c1c0865dfa04ce7bebb680c2ceec615f5c
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_typeck/diagnostics.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -753,28 +753,34 @@ You tried to use a structure initialization with a non-structure type.
753753
Example 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
```
767773
struct Inner {
768774
value: i32
769775
}
770776
771777
enum Foo {
772-
f(Inner)
778+
FirstValue(Inner)
773779
}
774780
775781
fn 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
```

0 commit comments

Comments
 (0)