@@ -301,6 +301,7 @@ struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
301
301
loans_out_of_scope_at_location : FxIndexMap < Location , Vec < BorrowIndex > > ,
302
302
}
303
303
304
+ #[ expect( dead_code) ]
304
305
impl < ' tcx > PoloniusOutOfScopePrecomputer < ' _ , ' tcx > {
305
306
fn compute (
306
307
body : & Body < ' tcx > ,
@@ -476,11 +477,18 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
476
477
if !tcx. sess . opts . unstable_opts . polonius . is_next_enabled ( ) {
477
478
calculate_borrows_out_of_scope_at_location ( body, regioncx, borrow_set)
478
479
} else {
479
- PoloniusOutOfScopePrecomputer :: compute ( body , regioncx , borrow_set )
480
+ unimplemented ! ( ) // This should probably be removed.
480
481
} ;
481
482
Borrows { tcx, body, borrow_set, borrows_out_of_scope_at_location }
482
483
}
483
484
485
+ /// A dummy `Borrows` with no useful information.
486
+ ///
487
+ /// Used for Polonius which doesn't need this.
488
+ pub fn dummy ( tcx : TyCtxt < ' tcx > , body : & ' a Body < ' tcx > , borrow_set : & ' a BorrowSet < ' tcx > ) -> Self {
489
+ Borrows { tcx, body, borrow_set, borrows_out_of_scope_at_location : Default :: default ( ) }
490
+ }
491
+
484
492
/// Add all borrows to the kill set, if those borrows are out of scope at `location`.
485
493
/// That means they went out of a nonlexical scope
486
494
fn kill_loans_out_of_scope_at_location (
@@ -563,6 +571,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
563
571
const NAME : & ' static str = "borrows" ;
564
572
565
573
fn bottom_value ( & self , _: & mir:: Body < ' tcx > ) -> Self :: Domain {
574
+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
575
+ return DenseBitSet :: new_empty ( 0 ) ;
576
+ }
577
+
566
578
// bottom = nothing is reserved or activated yet;
567
579
DenseBitSet :: new_empty ( self . borrow_set . len ( ) )
568
580
}
@@ -578,6 +590,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
578
590
_statement : & mir:: Statement < ' tcx > ,
579
591
location : Location ,
580
592
) {
593
+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
594
+ return ;
595
+ }
596
+
581
597
self . kill_loans_out_of_scope_at_location ( state, location) ;
582
598
}
583
599
@@ -587,6 +603,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
587
603
stmt : & mir:: Statement < ' tcx > ,
588
604
location : Location ,
589
605
) {
606
+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
607
+ return ;
608
+ }
609
+
590
610
match & stmt. kind {
591
611
mir:: StatementKind :: Assign ( box ( lhs, rhs) ) => {
592
612
if let mir:: Rvalue :: Ref ( _, _, place) = rhs {
@@ -636,6 +656,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
636
656
_terminator : & mir:: Terminator < ' tcx > ,
637
657
location : Location ,
638
658
) {
659
+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
660
+ return ;
661
+ }
662
+
639
663
self . kill_loans_out_of_scope_at_location ( state, location) ;
640
664
}
641
665
@@ -645,6 +669,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
645
669
terminator : & ' mir mir:: Terminator < ' tcx > ,
646
670
_location : Location ,
647
671
) -> TerminatorEdges < ' mir , ' tcx > {
672
+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
673
+ return terminator. edges ( ) ;
674
+ }
675
+
648
676
if let mir:: TerminatorKind :: InlineAsm { operands, .. } = & terminator. kind {
649
677
for op in operands {
650
678
if let mir:: InlineAsmOperand :: Out { place : Some ( place) , .. }
0 commit comments