@@ -301,6 +301,7 @@ struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
301301 loans_out_of_scope_at_location : FxIndexMap < Location , Vec < BorrowIndex > > ,
302302}
303303
304+ #[ expect( dead_code) ]
304305impl < ' tcx > PoloniusOutOfScopePrecomputer < ' _ , ' tcx > {
305306 fn compute (
306307 body : & Body < ' tcx > ,
@@ -476,11 +477,18 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
476477 if !tcx. sess . opts . unstable_opts . polonius . is_next_enabled ( ) {
477478 calculate_borrows_out_of_scope_at_location ( body, regioncx, borrow_set)
478479 } else {
479- PoloniusOutOfScopePrecomputer :: compute ( body , regioncx , borrow_set )
480+ unimplemented ! ( ) // This should probably be removed.
480481 } ;
481482 Borrows { tcx, body, borrow_set, borrows_out_of_scope_at_location }
482483 }
483484
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+
484492 /// Add all borrows to the kill set, if those borrows are out of scope at `location`.
485493 /// That means they went out of a nonlexical scope
486494 fn kill_loans_out_of_scope_at_location (
@@ -563,6 +571,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
563571 const NAME : & ' static str = "borrows" ;
564572
565573 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+
566578 // bottom = nothing is reserved or activated yet;
567579 DenseBitSet :: new_empty ( self . borrow_set . len ( ) )
568580 }
@@ -578,6 +590,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
578590 _statement : & mir:: Statement < ' tcx > ,
579591 location : Location ,
580592 ) {
593+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
594+ return ;
595+ }
596+
581597 self . kill_loans_out_of_scope_at_location ( state, location) ;
582598 }
583599
@@ -587,6 +603,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
587603 stmt : & mir:: Statement < ' tcx > ,
588604 location : Location ,
589605 ) {
606+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
607+ return ;
608+ }
609+
590610 match & stmt. kind {
591611 mir:: StatementKind :: Assign ( box ( lhs, rhs) ) => {
592612 if let mir:: Rvalue :: Ref ( _, _, place) = rhs {
@@ -636,6 +656,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
636656 _terminator : & mir:: Terminator < ' tcx > ,
637657 location : Location ,
638658 ) {
659+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
660+ return ;
661+ }
662+
639663 self . kill_loans_out_of_scope_at_location ( state, location) ;
640664 }
641665
@@ -645,6 +669,10 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
645669 terminator : & ' mir mir:: Terminator < ' tcx > ,
646670 _location : Location ,
647671 ) -> TerminatorEdges < ' mir , ' tcx > {
672+ if !self . tcx . sess . opts . unstable_opts . polonius . is_legacy_enabled ( ) {
673+ return terminator. edges ( ) ;
674+ }
675+
648676 if let mir:: TerminatorKind :: InlineAsm { operands, .. } = & terminator. kind {
649677 for op in operands {
650678 if let mir:: InlineAsmOperand :: Out { place : Some ( place) , .. }
0 commit comments