forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#103012 - chenyukang:fix-102806, r=davidtwco…
…,compiler-errors Suggest use .. to fill in the rest of the fields of Struct Fixes rust-lang#102806
- Loading branch information
Showing
5 changed files
with
98 additions
and
4 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,25 @@ | ||
#![allow(dead_code)] | ||
|
||
#[derive(Default)] | ||
struct V3 { | ||
x: f32, | ||
y: f32, | ||
z: f32, | ||
} | ||
|
||
fn pz(v: V3) { | ||
let _ = V3 { z: 0.0, ...v}; | ||
//~^ ERROR expected `..` | ||
|
||
let _ = V3 { z: 0.0, ...Default::default() }; | ||
//~^ ERROR expected `..` | ||
|
||
let _ = V3 { z: 0.0, ... }; | ||
//~^ expected identifier | ||
//~| ERROR missing fields `x` and `y` in initializer of `V3` | ||
|
||
let V3 { z: val, ... } = v; | ||
//~^ ERROR expected field pattern | ||
} | ||
|
||
fn main() {} |
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,45 @@ | ||
error: expected `..`, found `...` | ||
--> $DIR/issue-102806.rs:11:26 | ||
| | ||
LL | let _ = V3 { z: 0.0, ...v}; | ||
| ^^^ | ||
| | ||
help: use `..` to fill in the rest of the fields | ||
| | ||
LL | let _ = V3 { z: 0.0, ..v}; | ||
| ~~ | ||
|
||
error: expected `..`, found `...` | ||
--> $DIR/issue-102806.rs:14:26 | ||
| | ||
LL | let _ = V3 { z: 0.0, ...Default::default() }; | ||
| ^^^ | ||
| | ||
help: use `..` to fill in the rest of the fields | ||
| | ||
LL | let _ = V3 { z: 0.0, ..Default::default() }; | ||
| ~~ | ||
|
||
error: expected identifier, found `...` | ||
--> $DIR/issue-102806.rs:17:26 | ||
| | ||
LL | let _ = V3 { z: 0.0, ... }; | ||
| -- ^^^ expected identifier | ||
| | | ||
| while parsing this struct | ||
|
||
error: expected field pattern, found `...` | ||
--> $DIR/issue-102806.rs:21:22 | ||
| | ||
LL | let V3 { z: val, ... } = v; | ||
| ^^^ help: to omit remaining fields, use one fewer `.`: `..` | ||
|
||
error[E0063]: missing fields `x` and `y` in initializer of `V3` | ||
--> $DIR/issue-102806.rs:17:13 | ||
| | ||
LL | let _ = V3 { z: 0.0, ... }; | ||
| ^^ missing `x` and `y` | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0063`. |