-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error code for missing base expression in struct update syntax
- 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,E0796 | ||
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