-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[WIP] Warnings on long running constant evaluations #50859
Conversation
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.
Would you be so kind as to also add a bunch of tests that show various use cases of the lint with different lint levels and across const fn calls with different lint levels?
src/librustc_mir/interpret/step.rs
Outdated
.next() | ||
.expect("some part of a failing const eval must be local"); | ||
|
||
self.tcx.struct_span_lint_node( |
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.
So this alone won't cause const eval to abort. You should be able to run
tcx.lint_level_at_node(lint, id).0 == Level::Deny
to figure out whether the lint is denied.
This means you need to do that check for all stack frames (and not just the first local one), then report the lint at the most extreme level (forbid/deny) and if it is either forbid or deny, return a constant evaluation error here.
if all lint levels are allow or warn, continue the evaluation.
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.
N.B. There exists more than a single error lint level (e.g. Level::Fatal
iirc).
src/librustc_mir/interpret/step.rs
Outdated
.stack() | ||
.iter() | ||
.rev() | ||
.filter_map(|frame| self.tcx.hir.as_local_node_id(frame.instance.def_id())) |
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.
This should also filter out all frames that are Allow
, because the lint won't get reported there anyway, but if some frame wants to report the lint, then it should.
This means there might be no frames that we report anything on. In that case just don't emit the lint and only reset the terminators_remaining
counter.
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.
@oli-obk thank you, the suggestions will be addressed soon.
This comment has been minimized.
This comment has been minimized.
Actually, that travis failure makes me think... Maybe we should be using the This means that the changes described above should be done inside the |
7ac7abc
to
eeec217
Compare
@csmoe: It looks like your recent push didn't include any changes except the lint declaration, was that intentional? |
@TimNN That isn't all, I'm working on this, once it's done, I'd ping for review. |
@csmoe No problem, take your time! I was just surprised since the PR history indicates that earlier versions already contained code changes. |
Ping from triage, @csmoe ! We haven't heard from you in a while; are you still working on this? |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #51316) made this pull request unmergeable. Please resolve the merge conflicts. |
1ad4a20
to
4074cd0
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ping from triage @csmoe! It's been a while since we heard from you, will you have time to work on this again? |
Thank you for this PR @csmoe! Unfortunately we haven't heard from you on this in a while, so I'm closing the PR to keep things tidy. Don't worry though, if you'll have time again in the future please reopen this PR, we'll be happy to review it again! |
#Fixes #49980
r? @oli-obk