-
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
MIR: terminate unreachable blocks in construct_const #46877
Conversation
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.
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); | ||
} |
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.
If this is also in construct_fn
, can it be moved to Builder::finish
?
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.
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
.
@bors r+ |
📌 Commit 8dfc47a has been approved by |
@bors p=1 |
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.
☀️ Test successful - status-appveyor, status-travis |
Looks like we forgot to backport this for 1.23.0 (sorry about that!) so removing beta tags |
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.