diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 903bfc44c1d..60a218500ca 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -437,25 +437,42 @@ impl Session { pub fn print_llvm_passes(&self) -> bool { 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 { 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 { - 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 { 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 { 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 { match self.opts.borrowck_mode { mode @ BorrowckMode::Mir | mode @ BorrowckMode::Compare => mode, mode @ BorrowckMode::Ast => { - if self.features.borrow().nll { + if self.nll() { BorrowckMode::Mir } else { 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 { + // 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.mir_emit_validate > 0) || + self.opts.debugging_opts.mir_emit_validate > 0 || self.use_mir() } + pub fn lto(&self) -> bool { self.opts.cg.lto || self.target.target.options.requires_lto } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 7a6c2c25bf1..c907c97d6d3 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -72,10 +72,7 @@ fn mir_borrowck<'a, 'tcx>( let input_mir = tcx.mir_validated(def_id); debug!("run query mir_borrowck: {}", tcx.item_path_str(def_id)); - if { - !tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.use_mir() - && !tcx.sess.nll() - } { + if !tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.use_mir() { return None; }