]> git.lizzy.rs Git - rust.git/commit
Auto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk
authorbors <bors@rust-lang.org>
Fri, 29 Oct 2021 08:38:39 +0000 (08:38 +0000)
committerbors <bors@rust-lang.org>
Fri, 29 Oct 2021 08:38:39 +0000 (08:38 +0000)
commit37f70a0e1e04086aee7ae57fbefd6d4071953506
tree8fb2c5c02afc1fc099b2e7ebc5f2500ebe41f294
parent88a5a984fe95e0411dce4e8364f9630cadd3782c
parent93f85f5a9d97fc49826d0063c9db0a71602d3283
Auto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk

Consider indirect mutation during const qualification dataflow

Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.

Fixes #90124.

r? `@ecstatic-morse`
compiler/rustc_const_eval/src/transform/check_consts/check.rs