-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Issue-125323: ICE non-ADT in struct pattern when long time constant evaluation is in for loop #138679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shunpoco
wants to merge
2
commits into
rust-lang:master
Choose a base branch
from
Shunpoco:issue-125323
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+113
−52
Open
Issue-125323: ICE non-ADT in struct pattern when long time constant evaluation is in for loop #138679
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.rs
This file contains hidden or 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 @@ | ||
// The test confirms ICE-125323 is fixed. | ||
// | ||
// This warning tests there is no warning about dead code | ||
// when there is a constant evaluation error. | ||
#![warn(unused)] | ||
fn should_not_be_dead() {} | ||
|
||
fn main() { | ||
for _ in 0..0 { | ||
[(); loop {}]; //~ ERROR constant evaluation is taking a long time | ||
} | ||
|
||
should_not_be_dead(); | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr
This file contains hidden or 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/do-not-ice-long-constant-evaluation-in-for-loop.rs:10:14 | ||
| | ||
LL | [(); loop {}]; | ||
| ^^^^^^^ | ||
| | ||
= 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/do-not-ice-long-constant-evaluation-in-for-loop.rs:10:14 | ||
| | ||
LL | [(); loop {}]; | ||
| ^^^^^^^ | ||
= note: `#[deny(long_running_const_eval)]` on by default | ||
|
||
error: aborting due to 1 previous error | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to try out in a separate PR: doing this check in the lint infra itself so all lints profit from it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. If I revert this change, the ICE isn't solved. But as you said we should this check in the place where all lints get profits. For example, I found that visit_nested_body in late.rs looks a better place:
https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/late.rs#L91
If I move this check into visit_nested_body, both this ICE and ICE described in #138361 are solved.
So
Does this sound good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wfm, but I'm also happy merging the PR as is (squash the commits in that case pls), and then reverting this change here in the follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. thanks!
So I will keep this change as is in this PR then modify in the next PR