Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

csmoe
Copy link
Member

@csmoe csmoe commented May 18, 2018

#Fixes #49980

r? @oli-obk

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 18, 2018
Copy link
Contributor

@oli-obk oli-obk left a 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?

.next()
.expect("some part of a failing const eval must be local");

self.tcx.struct_span_lint_node(
Copy link
Contributor

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.

Copy link
Member

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).

.stack()
.iter()
.rev()
.filter_map(|frame| self.tcx.hir.as_local_node_id(frame.instance.def_id()))
Copy link
Contributor

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.

Copy link
Member Author

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.

@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented May 18, 2018

Actually, that travis failure makes me think... Maybe we should be using the report method here, so the lint prints out the entire stack trace. This should make the user experience related to debugging such cases much better.

This means that the changes described above should be done inside the report method, and it should also get a new argument: the lint ID (so we can distinguish between const_err and this new lint).

@csmoe csmoe force-pushed the lint_exec_time branch 2 times, most recently from 7ac7abc to eeec217 Compare May 18, 2018 14:23
@TimNN
Copy link
Contributor

TimNN commented May 22, 2018

@csmoe: It looks like your recent push didn't include any changes except the lint declaration, was that intentional?

@csmoe
Copy link
Member Author

csmoe commented May 24, 2018

@TimNN That isn't all, I'm working on this, once it's done, I'd ping for review.

@TimNN
Copy link
Contributor

TimNN commented May 24, 2018

@csmoe No problem, take your time! I was just surprised since the PR history indicates that earlier versions already contained code changes.

@TimNN TimNN added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 24, 2018
@shepmaster
Copy link
Member

Ping from triage, @csmoe ! We haven't heard from you in a while; are you still working on this?

@csmoe csmoe changed the title Warnings on long running constant evaluations [WIP] Warnings on long running constant evaluations Jun 5, 2018
@rust-highfive

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 6, 2018

☔ The latest upstream changes (presumably #51316) made this pull request unmergeable. Please resolve the merge conflicts.

@csmoe csmoe force-pushed the lint_exec_time branch 2 times, most recently from 1ad4a20 to 4074cd0 Compare June 10, 2018 09:04
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@pietroalbini
Copy link
Member

Ping from triage @csmoe! It's been a while since we heard from you, will you have time to work on this again?

@pietroalbini
Copy link
Member

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!

@pietroalbini pietroalbini added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants