Skip to content

Commit e980fb8

Browse files
spastorinonikomatsakis
authored andcommitted
feature nll implies borrowck=mir
1 parent 2019d69 commit e980fb8

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

src/librustc/session/mod.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use lint;
1818
use middle::allocator::AllocatorKind;
1919
use middle::dependency_format;
2020
use session::search_paths::PathKind;
21-
use session::config::DebugInfoLevel;
21+
use session::config::{BorrowckMode, DebugInfoLevel};
2222
use ty::tls;
2323
use util::nodemap::{FxHashMap, FxHashSet};
2424
use util::common::{duration_to_secs_str, ErrorReported};
@@ -440,16 +440,34 @@ impl Session {
440440
pub fn nll(&self) -> bool {
441441
self.features.borrow().nll || self.opts.debugging_opts.nll
442442
}
443+
pub fn use_mir(&self) -> bool {
444+
self.features.borrow().nll || self.opts.borrowck_mode.use_mir()
445+
}
443446
pub fn nll_dump_cause(&self) -> bool {
444447
self.opts.debugging_opts.nll_dump_cause
445448
}
446449
pub fn two_phase_borrows(&self) -> bool {
447450
self.features.borrow().nll || self.opts.debugging_opts.two_phase_borrows
448451
}
452+
pub fn borrowck_mode(&self) -> BorrowckMode {
453+
match self.opts.borrowck_mode {
454+
mode @ BorrowckMode::Mir |
455+
mode @ BorrowckMode::Compare => mode,
456+
457+
mode @ BorrowckMode::Ast => {
458+
if self.features.borrow().nll {
459+
BorrowckMode::Mir
460+
} else {
461+
mode
462+
}
463+
}
464+
465+
}
466+
}
449467
pub fn emit_end_regions(&self) -> bool {
450468
self.opts.debugging_opts.emit_end_regions ||
451469
(self.opts.debugging_opts.mir_emit_validate > 0) ||
452-
self.opts.borrowck_mode.use_mir()
470+
self.use_mir()
453471
}
454472
pub fn lto(&self) -> bool {
455473
self.opts.cg.lto || self.target.target.options.requires_lto

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'b, 'tcx: 'b> BorrowckErrors for BorrowckCtxt<'b, 'tcx> {
275275
o: Origin)
276276
-> DiagnosticBuilder<'a>
277277
{
278-
if !o.should_emit_errors(self.tcx.sess.opts.borrowck_mode) {
278+
if !o.should_emit_errors(self.tcx.sess.borrowck_mode()) {
279279
self.tcx.sess.diagnostic().cancel(&mut diag);
280280
}
281281
diag

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn mir_borrowck<'a, 'tcx>(
7373
debug!("run query mir_borrowck: {}", tcx.item_path_str(def_id));
7474

7575
if {
76-
!tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.opts.borrowck_mode.use_mir()
76+
!tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.use_mir()
7777
&& !tcx.sess.nll()
7878
} {
7979
return None;

src/librustc_mir/util/borrowck_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl<'b, 'gcx, 'tcx> BorrowckErrors for TyCtxt<'b, 'gcx, 'tcx> {
509509
o: Origin)
510510
-> DiagnosticBuilder<'a>
511511
{
512-
if !o.should_emit_errors(self.sess.opts.borrowck_mode) {
512+
if !o.should_emit_errors(self.sess.borrowck_mode()) {
513513
self.sess.diagnostic().cancel(&mut diag);
514514
}
515515
diag

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

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

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

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

0 commit comments

Comments
 (0)