-
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.
Check for presence of field in typeck results before visiting it
To prevent ICEs where the struct type is tainted by errors. Co-authored-by: Michael Goulet <[email protected]>
- Loading branch information
1 parent
cb4d9a1
commit 2668fa6
Showing
3 changed files
with
28 additions
and
1 deletion.
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
5 changes: 5 additions & 0 deletions
5
tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Regression test for issue #120615. | ||
|
||
fn main() { | ||
[(); loop {}].field; //~ ERROR constant evaluation is taking a long time | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.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,17 @@ | ||
error: constant evaluation is taking a long time | ||
--> $DIR/field-access-after-const-eval-fail-in-ty.rs:4:10 | ||
| | ||
LL | [(); loop {}].field; | ||
| ^^^^^^^ | ||
| | ||
= note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. | ||
If your compilation actually takes a long time, you can safely allow the lint. | ||
help: the constant being evaluated | ||
--> $DIR/field-access-after-const-eval-fail-in-ty.rs:4:10 | ||
| | ||
LL | [(); loop {}].field; | ||
| ^^^^^^^ | ||
= note: `#[deny(long_running_const_eval)]` on by default | ||
|
||
error: aborting due to 1 previous error | ||
|