forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#127575 - chenyukang:yukang-fix-struct-fields-…
…ice, r=compiler-errors Avoid "no field" error and ICE on recovered ADT variant Fixes rust-lang#126744 Fixes rust-lang#126344, a more general fix compared with rust-lang#127426 r? `@oli-obk` From `@compiler-errors` 's comment rust-lang#127502 (comment) Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
- Loading branch information
Showing
10 changed files
with
131 additions
and
32 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
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 | ||
|
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
3 changes: 1 addition & 2 deletions
3
tests/crashes/126744.rs → ...peck/struct-index-err-ice-issue-126744.rs
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,10 @@ | ||
error: expected identifier, found `,` | ||
--> $DIR/struct-index-err-ice-issue-126744.rs:1:11 | ||
| | ||
LL | struct X {,} | ||
| - ^ expected identifier | ||
| | | ||
| while parsing this struct | ||
|
||
error: aborting due to 1 previous error | ||
|