@@ -437,25 +437,42 @@ impl Session {
437437 pub fn print_llvm_passes ( & self ) -> bool {
438438 self . opts . debugging_opts . print_llvm_passes
439439 }
440+
441+ /// If true, we should use NLL-style region checking instead of
442+ /// lexical style.
440443 pub fn nll ( & self ) -> bool {
441444 self . features . borrow ( ) . nll || self . opts . debugging_opts . nll
442445 }
446+
447+ /// If true, we should use the MIR-based borrowck (we may *also* use
448+ /// the AST-based borrowck).
443449 pub fn use_mir ( & self ) -> bool {
444- self . features . borrow ( ) . nll || self . opts . borrowck_mode . use_mir ( )
450+ self . borrowck_mode ( ) . use_mir ( )
445451 }
452+
453+ /// If true, we should gather causal information during NLL
454+ /// checking. This will eventually be the normal thing, but right
455+ /// now it is too unoptimized.
446456 pub fn nll_dump_cause ( & self ) -> bool {
447457 self . opts . debugging_opts . nll_dump_cause
448458 }
459+
460+ /// If true, we should enable two-phase borrows checks. This is
461+ /// done with either `-Ztwo-phase-borrows` or with
462+ /// `#![feature(nll)]`.
449463 pub fn two_phase_borrows ( & self ) -> bool {
450464 self . features . borrow ( ) . nll || self . opts . debugging_opts . two_phase_borrows
451465 }
466+
467+ /// What mode(s) of borrowck should we run? AST? MIR? both?
468+ /// (Also considers the `#![feature(nll)]` setting.)
452469 pub fn borrowck_mode ( & self ) -> BorrowckMode {
453470 match self . opts . borrowck_mode {
454471 mode @ BorrowckMode :: Mir |
455472 mode @ BorrowckMode :: Compare => mode,
456473
457474 mode @ BorrowckMode :: Ast => {
458- if self . features . borrow ( ) . nll {
475+ if self . nll ( ) {
459476 BorrowckMode :: Mir
460477 } else {
461478 mode
@@ -464,11 +481,18 @@ impl Session {
464481
465482 }
466483 }
484+
485+ /// Should we emit EndRegion MIR statements? These are consumed by
486+ /// MIR borrowck, but not when NLL is used. They are also consumed
487+ /// by the validation stuff.
467488 pub fn emit_end_regions ( & self ) -> bool {
489+ // FIXME(#46875) -- we should not emit end regions when NLL is enabled,
490+ // but for now we can't stop doing so because it causes false positives
468491 self . opts . debugging_opts . emit_end_regions ||
469- ( self . opts . debugging_opts . mir_emit_validate > 0 ) ||
492+ self . opts . debugging_opts . mir_emit_validate > 0 ||
470493 self . use_mir ( )
471494 }
495+
472496 pub fn lto ( & self ) -> bool {
473497 self . opts . cg . lto || self . target . target . options . requires_lto
474498 }
0 commit comments