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

MIR: terminate unreachable blocks in construct_const #46877

Merged
merged 1 commit into from
Dec 21, 2017

Conversation

Deewiant
Copy link
Contributor

Fixes #46843.

#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.

Fixes rust-lang#46843.

rust-lang#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

if let Some(unreachable_block) = builder.cached_unreachable_block {
builder.cfg.terminate(unreachable_block, source_info,
TerminatorKind::Unreachable);
}
Copy link
Member

Choose a reason for hiding this comment

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

If this is also in construct_fn, can it be moved to Builder::finish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but it's not obvious to me how that could happen. The call to terminate depends on source_info which is defined differently here than in construct_fn, and doesn't seem like it could be obtained in a general fashion in Builder::finish.

@eddyb
Copy link
Member

eddyb commented Dec 20, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Dec 20, 2017

📌 Commit 8dfc47a has been approved by eddyb

@eddyb eddyb added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Dec 20, 2017
@kennytm kennytm added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 20, 2017
@arielb1
Copy link
Contributor

arielb1 commented Dec 21, 2017

@bors p=1

@bors
Copy link
Contributor

bors commented Dec 21, 2017

⌛ Testing commit 8dfc47a with merge b7b52cc...

bors added a commit that referenced this pull request Dec 21, 2017
MIR: terminate unreachable blocks in construct_const

Fixes #46843.

#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.
@bors
Copy link
Contributor

bors commented Dec 21, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing b7b52cc to master...

@bors bors merged commit 8dfc47a into rust-lang:master Dec 21, 2017
@Deewiant Deewiant deleted the gh46843 branch December 21, 2017 19:17
@nagisa nagisa added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 7, 2018
@alexcrichton
Copy link
Member

Looks like we forgot to backport this for 1.23.0 (sorry about that!) so removing beta tags

@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 10, 2018
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants