Auto merge of #46537 - pnkfelix:two-phase-borrows, r=arielb1
[MIR-borrowck] Two phase borrows This adds limited support for two-phase borrows as described in http://smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ The support is off by default; you opt into it via the flag `-Z two-phase-borrows` I have written "*limited* support" above because there are simple variants of the simple `v.push(v.len())` example that one would think should work but currently do not, such as the one documented in the test compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs (To be clear, that test is not describing something that is unsound. It is just providing an explicit example of a limitation in the implementation given in this PR. I have ideas on how to fix, but I want to land the work that is in this PR first, so that I can stop repeatedly rebasing this branch.)
This commit is contained in:
commit
84feab34e4
25 changed files with 1183 additions and 256 deletions
|
|
@ -1137,7 +1137,7 @@ impl<'tcx> Debug for Statement<'tcx> {
|
|||
|
||||
/// A path to a value; something that can be evaluated without
|
||||
/// changing or disturbing program state.
|
||||
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub enum Place<'tcx> {
|
||||
/// local variable
|
||||
Local(Local),
|
||||
|
|
@ -1151,7 +1151,7 @@ pub enum Place<'tcx> {
|
|||
|
||||
/// The def-id of a static, along with its normalized type (which is
|
||||
/// stored to avoid requiring normalization when reading MIR).
|
||||
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub struct Static<'tcx> {
|
||||
pub def_id: DefId,
|
||||
pub ty: Ty<'tcx>,
|
||||
|
|
|
|||
|
|
@ -1028,6 +1028,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
"emit EndRegion as part of MIR; enable transforms that solely process EndRegion"),
|
||||
borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
||||
"select which borrowck is used (`ast`, `mir`, or `compare`)"),
|
||||
two_phase_borrows: bool = (false, parse_bool, [UNTRACKED],
|
||||
"use two-phase reserved/active distinction for `&mut` borrows in MIR borrowck"),
|
||||
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
||||
"measure time of each rustc pass"),
|
||||
count_llvm_insns: bool = (false, parse_bool,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue