-
Notifications
You must be signed in to change notification settings - Fork 13.3k
MIR enabled rustc nightly warns about error in unreachable code #35316
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
Comments
Constant propagation should help with this. |
@nwin rustc never actually checked, this warning is a new MIR feature. |
Based on the shiny new dataflow framework, comes the constant propagation on MIR! Propagates constants, evaluates a number of binary, unary and cast operations and simplifies CFG based on the evaluations done. Code comments coming in subsequent PRs. Fixes rust-lang#35316
This is still the case today; however, I'm not sure that there's much purpose in keeping this issue around since it doesn't track anything specific other than "errors in unreachable code need to not happen," which as far as I can tell is really only fixable with constant propagation -- which this doesn't track. |
I'm going to close -- there's nothing inherently wrong with warning about unreachable code, and this issue isn't going to influence constant propagation being introduced into MIR/rustc. |
Compiling the following code using rustc+mir
emits the following warning
although the
else
branch is unreachable. Switching off MIR by using-Z orbit=off
causes the warning to disappear.Edit: It seems that
rustc
lost the ability to detect this unreachable branch. Usingif true {
instead causes the warning to disappear as well.The text was updated successfully, but these errors were encountered: