]> git.lizzy.rs Git - rust.git/commitdiff
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)
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.

1  2 
src/librustc/session/config.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_typeck/check/mod.rs

Simple merge
Simple merge