Do not project to uninhabited variant in JumpThreading + const printing + GVN#120350
Do not project to uninhabited variant in JumpThreading + const printing + GVN#120350compiler-errors wants to merge 2 commits intorust-lang:masterfrom
JumpThreading + const printing + GVN#120350Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
@bors r+ Thank you! |
|
@bors p=50 |
|
Why is this so high priority to fix? |
|
#120337 (comment) |
|
Well sorry, but the test isn't even accurate. Nightly will have to wait. @bors r- |
dc38470 to
4315b72
Compare
|
Less confident about the GVN change. cc @cjgillot |
| } | ||
| ProjectionElem::Downcast(name, index) => ProjectionElem::Downcast(name, index), | ||
| ProjectionElem::Downcast(name, index) => { | ||
| if let Some(ct) = self.eval_to_const(value) |
There was a problem hiding this comment.
We don't bail on the None case since GVN runs on polymorphic MIR. Is there a better uninhabited method for possibly polymorphic types?
JumpThreading + const printingJumpThreading + const printing + GVN
| let variant = ecx.read_discriminant(&op).ok()?; | ||
| if op.layout.for_variant(&ecx, variant).abi.is_uninhabited() { | ||
| return None; | ||
| } |
There was a problem hiding this comment.
I don't think we should have such checks everywhere. That's too fragile. We should just remove the assertion: #120367.
|
the assert got removed in #120367 (thank you Ralf!) |
Implements this check: #120347 (comment)
Interestingly, we also had to do this same check in
try_destructure_mir_constant_for_user_output. I guess it's because we're trying to print an uninhabited variant in the MIR opt output?Fixes #120337
r? oli-obk