Add error code for missing base expression in struct update syntax
This commit is contained in:
parent
5876c8cdfd
commit
f1b8b7d7ae
5 changed files with 38 additions and 6 deletions
|
@ -516,6 +516,7 @@ E0793: include_str!("./error_codes/E0793.md"),
|
|||
E0794: include_str!("./error_codes/E0794.md"),
|
||||
E0795: include_str!("./error_codes/E0795.md"),
|
||||
E0796: include_str!("./error_codes/E0796.md"),
|
||||
E0797: include_str!("./error_codes/E0797.md"),
|
||||
}
|
||||
|
||||
// Undocumented removed error codes. Note that many removed error codes are kept in the list above
|
||||
|
|
26
compiler/rustc_error_codes/src/error_codes/E0797.md
Normal file
26
compiler/rustc_error_codes/src/error_codes/E0797.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
Struct update syntax was used without a base expression.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0797
|
||||
struct Foo {
|
||||
fizz: u8,
|
||||
buzz: u8
|
||||
}
|
||||
|
||||
let f1 = Foo { fizz: 10, buzz: 1};
|
||||
let f2 = Foo { fizz: 10, .. }; // error
|
||||
```
|
||||
|
||||
Using struct update syntax requires a 'base expression'.
|
||||
This will be used to fill remaining fields.
|
||||
|
||||
```
|
||||
struct Foo {
|
||||
fizz: u8,
|
||||
buzz: u8
|
||||
}
|
||||
|
||||
let f1 = Foo { fizz: 10, buzz: 1};
|
||||
let f2 = Foo { fizz: 10, ..f1 };
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue