Skip to content

Commit 2019d69

Browse files
spastorinonikomatsakis
authored andcommitted
feature nll implies two-phase-borrows
1 parent 0b2db1e commit 2019d69

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/librustc/session/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,9 @@ impl Session {
443443
pub fn nll_dump_cause(&self) -> bool {
444444
self.opts.debugging_opts.nll_dump_cause
445445
}
446+
pub fn two_phase_borrows(&self) -> bool {
447+
self.features.borrow().nll || self.opts.debugging_opts.two_phase_borrows
448+
}
446449
pub fn emit_end_regions(&self) -> bool {
447450
self.opts.debugging_opts.emit_end_regions ||
448451
(self.opts.debugging_opts.mir_emit_validate > 0) ||

src/librustc_mir/borrow_check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
774774

775775
(Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut) => {
776776
// Reading from mere reservations of mutable-borrows is OK.
777-
if this.tcx.sess.opts.debugging_opts.two_phase_borrows && index.is_reservation()
777+
if this.tcx.sess.two_phase_borrows() && index.is_reservation()
778778
{
779779
return Control::Continue;
780780
}
@@ -922,7 +922,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
922922
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
923923
BorrowKind::Unique | BorrowKind::Mut => {
924924
let wk = WriteKind::MutableBorrow(bk);
925-
if self.tcx.sess.opts.debugging_opts.two_phase_borrows {
925+
if self.tcx.sess.two_phase_borrows() {
926926
(Deep, Reservation(wk))
927927
} else {
928928
(Deep, Write(wk))
@@ -1112,7 +1112,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
11121112
span: Span,
11131113
flow_state: &Flows<'cx, 'gcx, 'tcx>,
11141114
) {
1115-
if !self.tcx.sess.opts.debugging_opts.two_phase_borrows {
1115+
if !self.tcx.sess.two_phase_borrows() {
11161116
return;
11171117
}
11181118

src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
// revisions: lxl nll
1212
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
13-
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
13+
//[nll]compile-flags: -Z borrowck=mir
14+
15+
#![cfg_attr(nll, feature(nll))]
1416

1517
fn main() {
1618
let mut a = 0;

0 commit comments

Comments
 (0)