forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#106893 - clubby789:struct-update-help, r=compiler-errors Explain base expression for struct update syntax Fixes rust-lang#106890 `@rustbot` label +A-diagnostics
- Loading branch information
Showing
5 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters