-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #112199 - jieyouxu:issue-112188, r=compiler-errors
Fix suggestion for matching struct with `..` on both ends ### Before This PR ``` error: expected `}`, found `,` --> src\main.rs:8:17 | 8 | Foo { .., x, .. } => (), | --^ | | | | | expected `}` | `..` must be at the end and cannot have a trailing comma | help: move the `..` to the end of the field list | 8 - Foo { .., x, .. } => (), 8 + Foo { .., x, , .. } => (), | ``` ### After This PR ``` error: expected `}`, found `,` --> tests/ui/parser/issue-112188.rs:11:17 | 11 | let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` | --^- | | | | | expected `}` | `..` must be at the end and cannot have a trailing comma | help: remove the starting `..` ``` Fixes #112188.
- Loading branch information
Showing
5 changed files
with
111 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
struct Foo { x: i32 } | ||
|
||
fn main() { | ||
let f = Foo { x: 0 }; | ||
let Foo { .. } = f; | ||
let Foo { .. } = f; //~ ERROR expected `}`, found `,` | ||
let Foo { x, .. } = f; | ||
let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` | ||
let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` | ||
} |
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,14 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
struct Foo { x: i32 } | ||
|
||
fn main() { | ||
let f = Foo { x: 0 }; | ||
let Foo { .. } = f; | ||
let Foo { .., } = f; //~ ERROR expected `}`, found `,` | ||
let Foo { x, .. } = f; | ||
let Foo { .., x } = f; //~ ERROR expected `}`, found `,` | ||
let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` | ||
} |
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,37 @@ | ||
error: expected `}`, found `,` | ||
--> $DIR/issue-112188.rs:10:17 | ||
| | ||
LL | let Foo { .., } = f; | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| | help: remove this comma | ||
| `..` must be at the end and cannot have a trailing comma | ||
|
||
error: expected `}`, found `,` | ||
--> $DIR/issue-112188.rs:12:17 | ||
| | ||
LL | let Foo { .., x } = f; | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| `..` must be at the end and cannot have a trailing comma | ||
| | ||
help: move the `..` to the end of the field list | ||
| | ||
LL - let Foo { .., x } = f; | ||
LL + let Foo { x, .. } = f; | ||
| | ||
|
||
error: expected `}`, found `,` | ||
--> $DIR/issue-112188.rs:13:17 | ||
| | ||
LL | let Foo { .., x, .. } = f; | ||
| --^- | ||
| | | | ||
| | expected `}` | ||
| `..` must be at the end and cannot have a trailing comma | ||
| help: remove the starting `..` | ||
|
||
error: aborting due to 3 previous errors | ||
|
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