@@ -437,25 +437,42 @@ impl Session {
437
437
pub fn print_llvm_passes ( & self ) -> bool {
438
438
self . opts . debugging_opts . print_llvm_passes
439
439
}
440
+
441
+ /// If true, we should use NLL-style region checking instead of
442
+ /// lexical style.
440
443
pub fn nll ( & self ) -> bool {
441
444
self . features . borrow ( ) . nll || self . opts . debugging_opts . nll
442
445
}
446
+
447
+ /// If true, we should use the MIR-based borrowck (we may *also* use
448
+ /// the AST-based borrowck).
443
449
pub fn use_mir ( & self ) -> bool {
444
- self . features . borrow ( ) . nll || self . opts . borrowck_mode . use_mir ( )
450
+ self . borrowck_mode ( ) . use_mir ( )
445
451
}
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.
446
456
pub fn nll_dump_cause ( & self ) -> bool {
447
457
self . opts . debugging_opts . nll_dump_cause
448
458
}
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)]`.
449
463
pub fn two_phase_borrows ( & self ) -> bool {
450
464
self . features . borrow ( ) . nll || self . opts . debugging_opts . two_phase_borrows
451
465
}
466
+
467
+ /// What mode(s) of borrowck should we run? AST? MIR? both?
468
+ /// (Also considers the `#![feature(nll)]` setting.)
452
469
pub fn borrowck_mode ( & self ) -> BorrowckMode {
453
470
match self . opts . borrowck_mode {
454
471
mode @ BorrowckMode :: Mir |
455
472
mode @ BorrowckMode :: Compare => mode,
456
473
457
474
mode @ BorrowckMode :: Ast => {
458
- if self . features . borrow ( ) . nll {
475
+ if self . nll ( ) {
459
476
BorrowckMode :: Mir
460
477
} else {
461
478
mode
@@ -464,11 +481,18 @@ impl Session {
464
481
465
482
}
466
483
}
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.
467
488
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
468
491
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 ||
470
493
self . use_mir ( )
471
494
}
495
+
472
496
pub fn lto ( & self ) -> bool {
473
497
self . opts . cg . lto || self . target . target . options . requires_lto
474
498
}
0 commit comments