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

Do not ICE in the face of invalid enum discriminant #69903

Merged
merged 1 commit into from
Apr 16, 2020

Conversation

estebank
Copy link
Contributor

Fix #67377.

r? @pnkfelix

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 10, 2020
@estebank
Copy link
Contributor Author

I don't think this is the best way of doing it, but it is certainly a way to mitigate the issues.

@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

cc @oli-obk

fields: vec![],
base: None,
},
_ if ty.references_error() => {
// Handle degenerate input without ICE (#67377).
ExprKind::Literal { literal: ty::Const::zero_sized(cx.tcx, ty), user_ty: None }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if you use cx.tcx.types.err instead of ty here? That should avoid the TooGeneric and instead give us an AlreadyReported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushing that change as it is reasonable, but there's no change in the output. Could there be a better placeholder than ExprKind::Literal or ty::Const::zero_sized?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "change in the output"? If you change the delay_span_bug back to span_bug, will it still get triggered? I don't actually expect any stderr changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @estebank did you have a chance to try this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the requested change, reverting delay_span_bug change and making ty types.err. The span_bug triggers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for trying! I guess at this point in parser recovery we just have to give up.

@estebank
Copy link
Contributor Author

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned pnkfelix Mar 11, 2020
@bors

This comment has been minimized.

@oli-obk oli-obk 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. labels Apr 2, 2020
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 12, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Apr 14, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Apr 14, 2020

📌 Commit 187f270 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 14, 2020
Centril added a commit to Centril/rust that referenced this pull request Apr 15, 2020
Do not ICE in the face of invalid enum discriminant

Fix rust-lang#67377.

r? @pnkfelix
@Centril
Copy link
Contributor

Centril commented Apr 15, 2020

Failed in #71161 (comment), @bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 15, 2020
@estebank
Copy link
Contributor Author

@bors r=oli-obk rebased and reblessed

@bors
Copy link
Contributor

bors commented Apr 15, 2020

📌 Commit f47c4ff has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Apr 15, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 15, 2020
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 15, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 15, 2020
Do not ICE in the face of invalid enum discriminant

Fix rust-lang#67377.

r? @pnkfelix
This was referenced Apr 15, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 15, 2020
Rollup of 6 pull requests

Successful merges:

 - rust-lang#69903 (Do not ICE in the face of invalid enum discriminant)
 - rust-lang#70354 (Update RELEASES.md for 1.43.0)
 - rust-lang#70774 (End cleanup on rustdoc-js tools)
 - rust-lang#70990 (Improve rustdoc source code a bit)
 - rust-lang#71145 (Add illumos triple)
 - rust-lang#71166 (Clean up E0518 explanation)

Failed merges:

r? @ghost
@bors bors merged commit 03707b5 into rust-lang:master Apr 16, 2020
_ if ty.references_error() => {
// Handle degenerate input without ICE (#67377).
ExprKind::Literal {
literal: ty::Const::zero_sized(cx.tcx, cx.tcx.types.err),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use tcx.consts.err, doing it this way makes it slip past #71049, had I not come across this PR for a completely unrelated reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait how are we even getting here?! MIR isn't built if typeck_tables_of(def_id).is_tainted_by_errors and that's where ty comes from.

Comment on lines 2401 to +2406
Err(ErrorHandled::TooGeneric) => {
span_bug!(tcx.def_span(expr_did), "enum discriminant depends on generic arguments",)
tcx.sess.delay_span_bug(
tcx.def_span(expr_did),
"enum discriminant depends on generic arguments",
);
None
Copy link
Member

@eddyb eddyb Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be the actual change here, and it looks a lot like the "ty: use delay_span_bug in ty::AdtDef::eval_explicit_discr." commit from #70825.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

invalid syntax (unclosed brace) yields eventual ICE: unexpected ty: [type error]
7 participants