forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rust-lang#126344, skip report nonexisting_field error for recover…
…ed structs
- Loading branch information
1 parent
2976c59
commit f198542
Showing
3 changed files
with
72 additions
and
0 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,42 @@ | ||
struct Wrong { | ||
x: i32; //~ ERROR struct fields are separated by `,` | ||
y: i32, | ||
z: i32, | ||
h: i32, | ||
} | ||
|
||
fn oops(w: &Wrong) { | ||
w.x; | ||
} | ||
|
||
fn foo(w: &Wrong) { | ||
w.y; | ||
} | ||
|
||
fn haha(w: &Wrong) { | ||
w.z; | ||
} | ||
|
||
struct WrongWithType { | ||
x: 1, //~ ERROR expected type, found `1` | ||
y: i32, | ||
z: i32, | ||
h: i32, | ||
} | ||
|
||
fn oops_type(w: &WrongWithType) { | ||
w.x; | ||
} | ||
|
||
fn foo_type(w: &WrongWithType) { | ||
w.y; | ||
} | ||
|
||
fn haha_type(w: &WrongWithType) { | ||
w.z; | ||
} | ||
|
||
fn main() { | ||
let v = Wrong { x: 1, y: 2, z: 3, h: 4 }; | ||
let x = WrongWithType { x: 1, y: 2, z: 3, h: 4 }; | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/ui/pattern/struct-parser-recovery-issue-126344.stderr
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,18 @@ | ||
error: struct fields are separated by `,` | ||
--> $DIR/struct-parser-recovery-issue-126344.rs:2:11 | ||
| | ||
LL | struct Wrong { | ||
| ----- while parsing this struct | ||
LL | x: i32; | ||
| ^ help: replace `;` with `,` | ||
|
||
error: expected type, found `1` | ||
--> $DIR/struct-parser-recovery-issue-126344.rs:21:8 | ||
| | ||
LL | struct WrongWithType { | ||
| ------------- while parsing this struct | ||
LL | x: 1, | ||
| ^ expected type | ||
|
||
error: aborting due to 2 previous errors | ||
|