-
Notifications
You must be signed in to change notification settings - Fork 14k
Check tainted_by_error in LateLint #147876
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:lint-check-tainted-error
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.
+33
−12
Open
Changes from all commits
Commits
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 was deleted.
Oops, something went wrong.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ng-constant-evaluation-in-for-loop.stderr → ...onstant-evaluation-cause-dead-code.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
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,5 @@ | ||
| // The test confirms ICE-138361 is fixed. | ||
| fn main() { | ||
| [0; loop{}]; //~ ERROR constant evaluation is taking a long time | ||
| std::mem::transmute(4) | ||
| } |
17 changes: 17 additions & 0 deletions
17
tests/ui/consts/long-constant-evaluation-cause-ice-in-sty.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/long-constant-evaluation-cause-ice-in-sty.rs:3:7 | ||
| | | ||
| LL | [0; 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/long-constant-evaluation-cause-ice-in-sty.rs:3:7 | ||
| | | ||
| LL | [0; 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.
Considering this can be called unconditionally outside rustdoc, perform it further down where we do
self.context.cached_typeck_results.set(None);and just always set it to Some unless in rustdoc mode or if tainted (keep returning in the tainted case of course).The cache still needs to be an option as we also have lints outside of bodies
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,
Do you mean I should call typeck_body in the block which cached_typeck_results.set(None) is called or I should call typeck_body other place where rustdoc doesn't use?
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.
you can call it there, but still behind an !actually_rustdoc check, and then just overwrite the freshly set
Nonewith aSomeof the data you just loaded.At that point I think we can even change the method for obtaining the cached typeck results to just unwrap the option
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, let me take time to investigate. I think I need to understand how typeck_body works more.
Let me clarify, does "the method" point typeck_body?
Uh oh!
There was an error while loading. Please reload this page.
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.
No I meant
maybe_typeck_results, which currently has anor_else, but could now just remove the or_else and trust that it was already filled in