document and tweak the nll, use_mir, etc helpers
In particular, -Znll might as well imply -Zborrowck=mir by default, just like `#![feature(nll)]` does. Also, if NLL is in use, no reason to emit end regions. The NLL pass just strips them out anyway.
This commit is contained in:
parent
e980fb8bef
commit
cfa4ffa374
@ -437,25 +437,42 @@ impl Session {
|
|||||||
pub fn print_llvm_passes(&self) -> bool {
|
pub fn print_llvm_passes(&self) -> bool {
|
||||||
self.opts.debugging_opts.print_llvm_passes
|
self.opts.debugging_opts.print_llvm_passes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If true, we should use NLL-style region checking instead of
|
||||||
|
/// lexical style.
|
||||||
pub fn nll(&self) -> bool {
|
pub fn nll(&self) -> bool {
|
||||||
self.features.borrow().nll || self.opts.debugging_opts.nll
|
self.features.borrow().nll || self.opts.debugging_opts.nll
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If true, we should use the MIR-based borrowck (we may *also* use
|
||||||
|
/// the AST-based borrowck).
|
||||||
pub fn use_mir(&self) -> bool {
|
pub fn use_mir(&self) -> bool {
|
||||||
self.features.borrow().nll || self.opts.borrowck_mode.use_mir()
|
self.borrowck_mode().use_mir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If true, we should gather causal information during NLL
|
||||||
|
/// checking. This will eventually be the normal thing, but right
|
||||||
|
/// now it is too unoptimized.
|
||||||
pub fn nll_dump_cause(&self) -> bool {
|
pub fn nll_dump_cause(&self) -> bool {
|
||||||
self.opts.debugging_opts.nll_dump_cause
|
self.opts.debugging_opts.nll_dump_cause
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If true, we should enable two-phase borrows checks. This is
|
||||||
|
/// done with either `-Ztwo-phase-borrows` or with
|
||||||
|
/// `#![feature(nll)]`.
|
||||||
pub fn two_phase_borrows(&self) -> bool {
|
pub fn two_phase_borrows(&self) -> bool {
|
||||||
self.features.borrow().nll || self.opts.debugging_opts.two_phase_borrows
|
self.features.borrow().nll || self.opts.debugging_opts.two_phase_borrows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// What mode(s) of borrowck should we run? AST? MIR? both?
|
||||||
|
/// (Also considers the `#![feature(nll)]` setting.)
|
||||||
pub fn borrowck_mode(&self) -> BorrowckMode {
|
pub fn borrowck_mode(&self) -> BorrowckMode {
|
||||||
match self.opts.borrowck_mode {
|
match self.opts.borrowck_mode {
|
||||||
mode @ BorrowckMode::Mir |
|
mode @ BorrowckMode::Mir |
|
||||||
mode @ BorrowckMode::Compare => mode,
|
mode @ BorrowckMode::Compare => mode,
|
||||||
|
|
||||||
mode @ BorrowckMode::Ast => {
|
mode @ BorrowckMode::Ast => {
|
||||||
if self.features.borrow().nll {
|
if self.nll() {
|
||||||
BorrowckMode::Mir
|
BorrowckMode::Mir
|
||||||
} else {
|
} else {
|
||||||
mode
|
mode
|
||||||
@ -464,11 +481,18 @@ impl Session {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Should we emit EndRegion MIR statements? These are consumed by
|
||||||
|
/// MIR borrowck, but not when NLL is used. They are also consumed
|
||||||
|
/// by the validation stuff.
|
||||||
pub fn emit_end_regions(&self) -> bool {
|
pub fn emit_end_regions(&self) -> bool {
|
||||||
|
// FIXME(#46875) -- we should not emit end regions when NLL is enabled,
|
||||||
|
// but for now we can't stop doing so because it causes false positives
|
||||||
self.opts.debugging_opts.emit_end_regions ||
|
self.opts.debugging_opts.emit_end_regions ||
|
||||||
(self.opts.debugging_opts.mir_emit_validate > 0) ||
|
self.opts.debugging_opts.mir_emit_validate > 0 ||
|
||||||
self.use_mir()
|
self.use_mir()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lto(&self) -> bool {
|
pub fn lto(&self) -> bool {
|
||||||
self.opts.cg.lto || self.target.target.options.requires_lto
|
self.opts.cg.lto || self.target.target.options.requires_lto
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,7 @@ fn mir_borrowck<'a, 'tcx>(
|
|||||||
let input_mir = tcx.mir_validated(def_id);
|
let input_mir = tcx.mir_validated(def_id);
|
||||||
debug!("run query mir_borrowck: {}", tcx.item_path_str(def_id));
|
debug!("run query mir_borrowck: {}", tcx.item_path_str(def_id));
|
||||||
|
|
||||||
if {
|
if !tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.use_mir() {
|
||||||
!tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.use_mir()
|
|
||||||
&& !tcx.sess.nll()
|
|
||||||
} {
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user