]> git.lizzy.rs Git - rust.git/commit
Auto merge of #47489 - pnkfelix:limit-2pb-issue-46747, r=nikomatsakis
authorbors <bors@rust-lang.org>
Fri, 9 Feb 2018 02:26:43 +0000 (02:26 +0000)
committerbors <bors@rust-lang.org>
Fri, 9 Feb 2018 02:26:43 +0000 (02:26 +0000)
commitafa8acce251cda7ab1548640fdb769139a45f839
treebc933826b368226427af8894bc4de82291c7ea9a
parent932c736479f43dc8893a924946e4335d8e308c2e
parentb55cd8cc7c55a50941cc55cd399f6d5aebdf77f8
Auto merge of #47489 - pnkfelix:limit-2pb-issue-46747, r=nikomatsakis

NLL: Limit two-phase borrows to autoref-introduced borrows

This imposes a restriction on two-phase borrows so that it only applies to autoref-introduced borrows.

The goal is to ensure that our initial deployment of two-phase borrows is very conservative. We want it to still cover the `v.push(v.len());` example, but we do not want it to cover cases like `let imm = &v; let mu = &mut v; mu.push(imm.len());`

(Why do we want it to be conservative? Because when you are not conservative, then the results you get, at least with the current analysis, are tightly coupled to details of the MIR construction that we would rather remain invisible to the end user.)

Fix #46747

I decided, for this PR, to add a debug-flag `-Z two-phase-beyond-autoref`, to re-enable the more general approach. But my intention here is *not* that we would eventually turn on that debugflag by default; the main reason I added it was that I thought it was useful for writing tests to be able to write source that looks like desugared MIR.
src/librustc/session/config.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_typeck/check/mod.rs