Skip to content

Commit

Permalink
feature nll implies two-phase-borrows
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino authored and nikomatsakis committed Dec 20, 2017
1 parent 0b2db1e commit 2019d69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ impl Session {
pub fn nll_dump_cause(&self) -> bool {
self.opts.debugging_opts.nll_dump_cause
}
pub fn two_phase_borrows(&self) -> bool {
self.features.borrow().nll || self.opts.debugging_opts.two_phase_borrows
}
pub fn emit_end_regions(&self) -> bool {
self.opts.debugging_opts.emit_end_regions ||
(self.opts.debugging_opts.mir_emit_validate > 0) ||
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {

(Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut) => {
// Reading from mere reservations of mutable-borrows is OK.
if this.tcx.sess.opts.debugging_opts.two_phase_borrows && index.is_reservation()
if this.tcx.sess.two_phase_borrows() && index.is_reservation()
{
return Control::Continue;
}
Expand Down Expand Up @@ -922,7 +922,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
BorrowKind::Unique | BorrowKind::Mut => {
let wk = WriteKind::MutableBorrow(bk);
if self.tcx.sess.opts.debugging_opts.two_phase_borrows {
if self.tcx.sess.two_phase_borrows() {
(Deep, Reservation(wk))
} else {
(Deep, Write(wk))
Expand Down Expand Up @@ -1112,7 +1112,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
span: Span,
flow_state: &Flows<'cx, 'gcx, 'tcx>,
) {
if !self.tcx.sess.opts.debugging_opts.two_phase_borrows {
if !self.tcx.sess.two_phase_borrows() {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

// revisions: lxl nll
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
//[nll]compile-flags: -Z borrowck=mir

#![cfg_attr(nll, feature(nll))]

fn main() {
let mut a = 0;
Expand Down

0 comments on commit 2019d69

Please sign in to comment.