@@ -8,7 +8,10 @@ use rustc_middle::mir::{
88} ; 
99use  rustc_middle:: ty:: { RegionVid ,  TyCtxt } ; 
1010use  rustc_mir_dataflow:: fmt:: DebugWithContext ; 
11- use  rustc_mir_dataflow:: impls:: { EverInitializedPlaces ,  MaybeUninitializedPlaces } ; 
11+ use  rustc_mir_dataflow:: impls:: { 
12+     EverInitializedPlaces ,  EverInitializedPlacesDomain ,  MaybeUninitializedPlaces , 
13+     MaybeUninitializedPlacesDomain , 
14+ } ; 
1215use  rustc_mir_dataflow:: { Analysis ,  GenKill ,  JoinSemiLattice ,  SwitchIntEdgeEffects } ; 
1316use  tracing:: debug; 
1417
@@ -24,7 +27,7 @@ pub(crate) struct Borrowck<'a, 'tcx> {
2427} 
2528
2629impl < ' a ,  ' tcx >  Analysis < ' tcx >  for  Borrowck < ' a ,  ' tcx >  { 
27-     type  Domain  = BorrowckDomain < ' a ,   ' tcx > ; 
30+     type  Domain  = BorrowckDomain ; 
2831
2932    const  NAME :  & ' static  str  = "borrowck" ; 
3033
@@ -41,48 +44,48 @@ impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
4144        unreachable ! ( ) ; 
4245    } 
4346
44-     fn  apply_before_statement_effect ( 
47+     fn  apply_early_statement_effect ( 
4548        & mut  self , 
4649        state :  & mut  Self :: Domain , 
4750        stmt :  & mir:: Statement < ' tcx > , 
4851        loc :  Location , 
4952    )  { 
50-         self . borrows . apply_before_statement_effect ( & mut  state. borrows ,  stmt,  loc) ; 
51-         self . uninits . apply_before_statement_effect ( & mut  state. uninits ,  stmt,  loc) ; 
52-         self . ever_inits . apply_before_statement_effect ( & mut  state. ever_inits ,  stmt,  loc) ; 
53+         self . borrows . apply_early_statement_effect ( & mut  state. borrows ,  stmt,  loc) ; 
54+         self . uninits . apply_early_statement_effect ( & mut  state. uninits ,  stmt,  loc) ; 
55+         self . ever_inits . apply_early_statement_effect ( & mut  state. ever_inits ,  stmt,  loc) ; 
5356    } 
5457
55-     fn  apply_statement_effect ( 
58+     fn  apply_primary_statement_effect ( 
5659        & mut  self , 
5760        state :  & mut  Self :: Domain , 
5861        stmt :  & mir:: Statement < ' tcx > , 
5962        loc :  Location , 
6063    )  { 
61-         self . borrows . apply_statement_effect ( & mut  state. borrows ,  stmt,  loc) ; 
62-         self . uninits . apply_statement_effect ( & mut  state. uninits ,  stmt,  loc) ; 
63-         self . ever_inits . apply_statement_effect ( & mut  state. ever_inits ,  stmt,  loc) ; 
64+         self . borrows . apply_primary_statement_effect ( & mut  state. borrows ,  stmt,  loc) ; 
65+         self . uninits . apply_primary_statement_effect ( & mut  state. uninits ,  stmt,  loc) ; 
66+         self . ever_inits . apply_primary_statement_effect ( & mut  state. ever_inits ,  stmt,  loc) ; 
6467    } 
6568
66-     fn  apply_before_terminator_effect ( 
69+     fn  apply_early_terminator_effect ( 
6770        & mut  self , 
6871        state :  & mut  Self :: Domain , 
6972        term :  & mir:: Terminator < ' tcx > , 
7073        loc :  Location , 
7174    )  { 
72-         self . borrows . apply_before_terminator_effect ( & mut  state. borrows ,  term,  loc) ; 
73-         self . uninits . apply_before_terminator_effect ( & mut  state. uninits ,  term,  loc) ; 
74-         self . ever_inits . apply_before_terminator_effect ( & mut  state. ever_inits ,  term,  loc) ; 
75+         self . borrows . apply_early_terminator_effect ( & mut  state. borrows ,  term,  loc) ; 
76+         self . uninits . apply_early_terminator_effect ( & mut  state. uninits ,  term,  loc) ; 
77+         self . ever_inits . apply_early_terminator_effect ( & mut  state. ever_inits ,  term,  loc) ; 
7578    } 
7679
77-     fn  apply_terminator_effect < ' mir > ( 
80+     fn  apply_primary_terminator_effect < ' mir > ( 
7881        & mut  self , 
7982        state :  & mut  Self :: Domain , 
8083        term :  & ' mir  mir:: Terminator < ' tcx > , 
8184        loc :  Location , 
8285    )  -> TerminatorEdges < ' mir ,  ' tcx >  { 
83-         self . borrows . apply_terminator_effect ( & mut  state. borrows ,  term,  loc) ; 
84-         self . uninits . apply_terminator_effect ( & mut  state. uninits ,  term,  loc) ; 
85-         self . ever_inits . apply_terminator_effect ( & mut  state. ever_inits ,  term,  loc) ; 
86+         self . borrows . apply_primary_terminator_effect ( & mut  state. borrows ,  term,  loc) ; 
87+         self . uninits . apply_primary_terminator_effect ( & mut  state. uninits ,  term,  loc) ; 
88+         self . ever_inits . apply_primary_terminator_effect ( & mut  state. ever_inits ,  term,  loc) ; 
8689
8790        // This return value doesn't matter. It's only used by `iterate_to_fixpoint`, which this 
8891        // analysis doesn't use. 
@@ -110,14 +113,14 @@ impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
110113    } 
111114} 
112115
113- impl  JoinSemiLattice  for  BorrowckDomain < ' _ ,   ' _ >  { 
116+ impl  JoinSemiLattice  for  BorrowckDomain  { 
114117    fn  join ( & mut  self ,  _other :  & Self )  -> bool  { 
115118        // This is only reachable from `iterate_to_fixpoint`, which this analysis doesn't use. 
116119        unreachable ! ( ) ; 
117120    } 
118121} 
119122
120- impl < ' tcx ,  C >  DebugWithContext < C >  for  BorrowckDomain < ' _ ,   ' tcx > 
123+ impl < ' tcx ,  C >  DebugWithContext < C >  for  BorrowckDomain 
121124where 
122125    C :  rustc_mir_dataflow:: move_paths:: HasMoveData < ' tcx > , 
123126{ 
@@ -160,10 +163,10 @@ where
160163
161164/// The transient state of the dataflow analyses used by the borrow checker. 
162165#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
163- pub ( crate )  struct  BorrowckDomain < ' a ,   ' tcx >  { 
164-     pub ( crate )  borrows :  < Borrows < ' a ,   ' tcx >   as   Analysis < ' tcx > > :: Domain , 
165-     pub ( crate )  uninits :  < MaybeUninitializedPlaces < ' a ,   ' tcx >   as   Analysis < ' tcx > > :: Domain , 
166-     pub ( crate )  ever_inits :  < EverInitializedPlaces < ' a ,   ' tcx >   as   Analysis < ' tcx > > :: Domain , 
166+ pub ( crate )  struct  BorrowckDomain  { 
167+     pub ( crate )  borrows :  BorrowsDomain , 
168+     pub ( crate )  uninits :  MaybeUninitializedPlacesDomain , 
169+     pub ( crate )  ever_inits :  EverInitializedPlacesDomain , 
167170} 
168171
169172rustc_index:: newtype_index! { 
@@ -503,7 +506,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
503506/// That means they went out of a nonlexical scope 
504507fn  kill_loans_out_of_scope_at_location ( 
505508        & self , 
506-         trans :  & mut  <Self  as  Analysis < ' tcx > >:: Domain , 
509+         state :  & mut  <Self  as  Analysis < ' tcx > >:: Domain , 
507510        location :  Location , 
508511    )  { 
509512        // NOTE: The state associated with a given `location` 
@@ -518,14 +521,14 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
518521        // region, then setting that gen-bit will override any 
519522        // potential kill introduced here. 
520523        if  let  Some ( indices)  = self . borrows_out_of_scope_at_location . get ( & location)  { 
521-             trans . kill_all ( indices. iter ( ) . copied ( ) ) ; 
524+             state . kill_all ( indices. iter ( ) . copied ( ) ) ; 
522525        } 
523526    } 
524527
525528    /// Kill any borrows that conflict with `place`. 
526529fn  kill_borrows_on_place ( 
527530        & self , 
528-         trans :  & mut  <Self  as  Analysis < ' tcx > >:: Domain , 
531+         state :  & mut  <Self  as  Analysis < ' tcx > >:: Domain , 
529532        place :  Place < ' tcx > , 
530533    )  { 
531534        debug ! ( "kill_borrows_on_place: place={:?}" ,  place) ; 
@@ -543,7 +546,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
543546        // `places_conflict` for every borrow. 
544547        if  place. projection . is_empty ( )  { 
545548            if  !self . body . local_decls [ place. local ] . is_ref_to_static ( )  { 
546-                 trans . kill_all ( other_borrows_of_local) ; 
549+                 state . kill_all ( other_borrows_of_local) ; 
547550            } 
548551            return ; 
549552        } 
@@ -562,10 +565,12 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
562565            ) 
563566        } ) ; 
564567
565-         trans . kill_all ( definitely_conflicting_borrows) ; 
568+         state . kill_all ( definitely_conflicting_borrows) ; 
566569    } 
567570} 
568571
572+ type  BorrowsDomain  = BitSet < BorrowIndex > ; 
573+ 
569574/// Forward dataflow computation of the set of borrows that are in scope at a particular location. 
570575/// - we gen the introduced loans 
571576/// - we kill loans on locals going out of (regular) scope 
@@ -574,7 +579,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
574579/// - we also kill loans of conflicting places when overwriting a shared path: e.g. borrows of 
575580///   `a.b.c` when `a` is overwritten. 
576581impl < ' tcx >  rustc_mir_dataflow:: Analysis < ' tcx >  for  Borrows < ' _ ,  ' tcx >  { 
577-     type  Domain  = BitSet < BorrowIndex > ; 
582+     type  Domain  = BorrowsDomain ; 
578583
579584    const  NAME :  & ' static  str  = "borrows" ; 
580585
@@ -588,18 +593,18 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
588593        // function execution, so this method has no effect. 
589594    } 
590595
591-     fn  apply_before_statement_effect ( 
596+     fn  apply_early_statement_effect ( 
592597        & mut  self , 
593-         trans :  & mut  Self :: Domain , 
598+         state :  & mut  Self :: Domain , 
594599        _statement :  & mir:: Statement < ' tcx > , 
595600        location :  Location , 
596601    )  { 
597-         self . kill_loans_out_of_scope_at_location ( trans ,  location) ; 
602+         self . kill_loans_out_of_scope_at_location ( state ,  location) ; 
598603    } 
599604
600-     fn  apply_statement_effect ( 
605+     fn  apply_primary_statement_effect ( 
601606        & mut  self , 
602-         trans :  & mut  Self :: Domain , 
607+         state :  & mut  Self :: Domain , 
603608        stmt :  & mir:: Statement < ' tcx > , 
604609        location :  Location , 
605610    )  { 
@@ -617,18 +622,18 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
617622                        panic ! ( "could not find BorrowIndex for location {location:?}" ) ; 
618623                    } ) ; 
619624
620-                     trans . gen_ ( index) ; 
625+                     state . gen_ ( index) ; 
621626                } 
622627
623628                // Make sure there are no remaining borrows for variables 
624629                // that are assigned over. 
625-                 self . kill_borrows_on_place ( trans ,  * lhs) ; 
630+                 self . kill_borrows_on_place ( state ,  * lhs) ; 
626631            } 
627632
628633            mir:: StatementKind :: StorageDead ( local)  => { 
629634                // Make sure there are no remaining borrows for locals that 
630635                // are gone out of scope. 
631-                 self . kill_borrows_on_place ( trans ,  Place :: from ( * local) ) ; 
636+                 self . kill_borrows_on_place ( state ,  Place :: from ( * local) ) ; 
632637            } 
633638
634639            mir:: StatementKind :: FakeRead ( ..) 
@@ -646,18 +651,18 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
646651        } 
647652    } 
648653
649-     fn  apply_before_terminator_effect ( 
654+     fn  apply_early_terminator_effect ( 
650655        & mut  self , 
651-         trans :  & mut  Self :: Domain , 
656+         state :  & mut  Self :: Domain , 
652657        _terminator :  & mir:: Terminator < ' tcx > , 
653658        location :  Location , 
654659    )  { 
655-         self . kill_loans_out_of_scope_at_location ( trans ,  location) ; 
660+         self . kill_loans_out_of_scope_at_location ( state ,  location) ; 
656661    } 
657662
658-     fn  apply_terminator_effect < ' mir > ( 
663+     fn  apply_primary_terminator_effect < ' mir > ( 
659664        & mut  self , 
660-         trans :  & mut  Self :: Domain , 
665+         state :  & mut  Self :: Domain , 
661666        terminator :  & ' mir  mir:: Terminator < ' tcx > , 
662667        _location :  Location , 
663668    )  -> TerminatorEdges < ' mir ,  ' tcx >  { 
@@ -666,7 +671,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
666671                if  let  mir:: InlineAsmOperand :: Out  {  place :  Some ( place) ,  .. } 
667672                | mir:: InlineAsmOperand :: InOut  {  out_place :  Some ( place) ,  .. }  = * op
668673                { 
669-                     self . kill_borrows_on_place ( trans ,  place) ; 
674+                     self . kill_borrows_on_place ( state ,  place) ; 
670675                } 
671676            } 
672677        } 
0 commit comments