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

Use track_errors instead of hand-rolling such a check #59215

Closed
oli-obk opened this issue Mar 15, 2019 · 4 comments
Closed

Use track_errors instead of hand-rolling such a check #59215

oli-obk opened this issue Mar 15, 2019 · 4 comments
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Mar 15, 2019

Const eval asserts that reporting an error for statics actually worked. This is not only done in a wrong way (checks for no error having happened in the entire compilation), it's also very fragile. We should instead use the track_errors method around the report_as_error call, and in case track_errors returns Ok, we need to do the delay_span_bug.

The relevant code that needs to be changed can be found in

let reported_err = err.report_as_error(ecx.tcx,
"could not evaluate static initializer");
// Ensure that if the above error was either `TooGeneric` or `Reported`
// an error must be reported.
if tcx.sess.err_count() == 0 {
tcx.sess.delay_span_bug(err.span,
&format!("static eval failure did not emit an error: {:#?}",
reported_err));
}
reported_err

@oli-obk oli-obk added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. A-const-eval Area: Constant evaluation (MIR interpretation) labels Mar 15, 2019
@estebank
Copy link
Contributor

Wouldn't using track_errors cause the compiler to stop at const evaluation? Ideally we would want the compiler to choose a reasonable recovery value (just a binding of TyErr?) and continue to minimize the loop of "fix 5 errors, get 300 errors" (#39275).

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

track_errors doesn't actually stop anything. It just gives you a Result::Err if new errors occured and a Result::Ok otherwise.

@JohnTitor
Copy link
Member

@oli-obk I want to solve this, could I open a PR(and ask you to review)?

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 22, 2019

Jup! It's all yours!

Centril added a commit to Centril/rust that referenced this issue Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

3 participants