feature nll implies borrowck=mir

This commit is contained in:
Santiago Pastorino 2017-12-19 15:47:59 -03:00 committed by Niko Matsakis
parent 2019d69f61
commit e980fb8bef
5 changed files with 23 additions and 6 deletions

View File

@ -18,7 +18,7 @@ use lint;
use middle::allocator::AllocatorKind;
use middle::dependency_format;
use session::search_paths::PathKind;
use session::config::DebugInfoLevel;
use session::config::{BorrowckMode, DebugInfoLevel};
use ty::tls;
use util::nodemap::{FxHashMap, FxHashSet};
use util::common::{duration_to_secs_str, ErrorReported};
@ -440,16 +440,34 @@ impl Session {
pub fn nll(&self) -> bool {
self.features.borrow().nll || self.opts.debugging_opts.nll
}
pub fn use_mir(&self) -> bool {
self.features.borrow().nll || self.opts.borrowck_mode.use_mir()
}
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 borrowck_mode(&self) -> BorrowckMode {
match self.opts.borrowck_mode {
mode @ BorrowckMode::Mir |
mode @ BorrowckMode::Compare => mode,
mode @ BorrowckMode::Ast => {
if self.features.borrow().nll {
BorrowckMode::Mir
} else {
mode
}
}
}
}
pub fn emit_end_regions(&self) -> bool {
self.opts.debugging_opts.emit_end_regions ||
(self.opts.debugging_opts.mir_emit_validate > 0) ||
self.opts.borrowck_mode.use_mir()
self.use_mir()
}
pub fn lto(&self) -> bool {
self.opts.cg.lto || self.target.target.options.requires_lto

View File

@ -275,7 +275,7 @@ impl<'b, 'tcx: 'b> BorrowckErrors for BorrowckCtxt<'b, 'tcx> {
o: Origin)
-> DiagnosticBuilder<'a>
{
if !o.should_emit_errors(self.tcx.sess.opts.borrowck_mode) {
if !o.should_emit_errors(self.tcx.sess.borrowck_mode()) {
self.tcx.sess.diagnostic().cancel(&mut diag);
}
diag

View File

@ -73,7 +73,7 @@ fn mir_borrowck<'a, 'tcx>(
debug!("run query mir_borrowck: {}", tcx.item_path_str(def_id));
if {
!tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.opts.borrowck_mode.use_mir()
!tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.use_mir()
&& !tcx.sess.nll()
} {
return None;

View File

@ -509,7 +509,7 @@ impl<'b, 'gcx, 'tcx> BorrowckErrors for TyCtxt<'b, 'gcx, 'tcx> {
o: Origin)
-> DiagnosticBuilder<'a>
{
if !o.should_emit_errors(self.sess.opts.borrowck_mode) {
if !o.should_emit_errors(self.sess.borrowck_mode()) {
self.sess.diagnostic().cancel(&mut diag);
}
diag

View File

@ -10,7 +10,6 @@
// revisions: lxl nll
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
//[nll]compile-flags: -Z borrowck=mir
#![cfg_attr(nll, feature(nll))]