]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obk
authorTyler Mandry <tmandry@gmail.com>
Thu, 30 Apr 2020 22:23:17 +0000 (15:23 -0700)
committerGitHub <noreply@github.com>
Thu, 30 Apr 2020 22:23:17 +0000 (15:23 -0700)
commita8e0511b3288f40570812fe6524e0d80cf630f2c
tree06b28d2cb7806fb0bd291474ed3028c43aecc1da
parent8192cb6ea3e4456519bce0b176af221b960fd289
parent0592976f7ee4b31046e3d23457699ef038c3e6e7
Rollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obk

Allow `Downcast` projections unconditionally in const-checking

`ProjectionElem::Downcast` sounds scary, but it's really just the projection we use to access a particular enum variant. They usually appear in the lowering of a `match` statement, so they have been associated with control flow in const-checking, but they don't do any control flow by themselves. We already have a HIR pass that looks for `if` and `match` (even ones that have 1 or fewer reachable branches). That pass is double-checked by a MIR pass that looks for `SwitchInt`s and `FakeRead`s for match scrutinees. In my opinion, there's no need to look for `Downcast` as well.

r? @oli-obk
src/librustc_mir/transform/check_consts/validation.rs