Skip to content

Commit 612221f

Browse files
Improve E0063 error explanation
1 parent 9e51cee commit 612221f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,31 @@ fn main() {
670670

671671
E0063: r##"
672672
This error indicates that during an attempt to build a struct or struct-like
673-
enum variant, one of the fields was not provided. Each field should be
674-
specified exactly once.
673+
enum variant, one of the fields was not provided. Erroneous code example:
674+
675+
```
676+
struct Foo {
677+
x: i32,
678+
y: i32
679+
}
680+
681+
fn main() {
682+
let x = Foo { x: 0 }; // error: missing field: `y`
683+
}
684+
```
685+
686+
Each field should be specified exactly once. Example:
687+
688+
```
689+
struct Foo {
690+
x: i32,
691+
y: i32
692+
}
693+
694+
fn main() {
695+
let x = Foo { x: 0, y: 0 }; // ok!
696+
}
697+
```
675698
"##,
676699

677700
E0066: r##"

0 commit comments

Comments
 (0)