@@ -8,6 +8,7 @@ use crate::dataflow::{BitDenotation, DataflowResults, GenKillSet};
88use crate :: dataflow:: move_paths:: { HasMoveData , MovePathIndex } ;
99
1010use std:: iter;
11+ use std:: borrow:: Borrow ;
1112
1213/// A trait for "cartesian products" of multiple FlowAtLocation.
1314///
@@ -60,18 +61,20 @@ pub trait FlowsAtLocation {
6061/// (e.g., via `reconstruct_statement_effect` and
6162/// `reconstruct_terminator_effect`; don't forget to call
6263/// `apply_local_effect`).
63- pub struct FlowAtLocation < ' tcx , BD >
64+ pub struct FlowAtLocation < ' tcx , BD , DR = DataflowResults < ' tcx , BD > >
6465where
6566 BD : BitDenotation < ' tcx > ,
67+ DR : Borrow < DataflowResults < ' tcx , BD > > ,
6668{
67- base_results : DataflowResults < ' tcx , BD > ,
69+ base_results : DR ,
6870 curr_state : BitSet < BD :: Idx > ,
6971 stmt_trans : GenKillSet < BD :: Idx > ,
7072}
7173
72- impl < ' tcx , BD > FlowAtLocation < ' tcx , BD >
74+ impl < ' tcx , BD , DR > FlowAtLocation < ' tcx , BD , DR >
7375where
7476 BD : BitDenotation < ' tcx > ,
77+ DR : Borrow < DataflowResults < ' tcx , BD > > ,
7578{
7679 /// Iterate over each bit set in the current state.
7780 pub fn each_state_bit < F > ( & self , f : F )
9194 self . stmt_trans . gen_set . iter ( ) . for_each ( f)
9295 }
9396
94- pub fn new ( results : DataflowResults < ' tcx , BD > ) -> Self {
95- let bits_per_block = results. sets ( ) . bits_per_block ( ) ;
97+ pub fn new ( results : DR ) -> Self {
98+ let bits_per_block = results. borrow ( ) . sets ( ) . bits_per_block ( ) ;
9699 let curr_state = BitSet :: new_empty ( bits_per_block) ;
97100 let stmt_trans = GenKillSet :: from_elem ( HybridBitSet :: new_empty ( bits_per_block) ) ;
98101 FlowAtLocation {
@@ -104,7 +107,7 @@ where
104107
105108 /// Access the underlying operator.
106109 pub fn operator ( & self ) -> & BD {
107- self . base_results . operator ( )
110+ self . base_results . borrow ( ) . operator ( )
108111 }
109112
110113 pub fn contains ( & self , x : BD :: Idx ) -> bool {
@@ -134,39 +137,45 @@ where
134137 }
135138}
136139
137- impl < ' tcx , BD > FlowsAtLocation for FlowAtLocation < ' tcx , BD >
138- where BD : BitDenotation < ' tcx >
140+ impl < ' tcx , BD , DR > FlowsAtLocation for FlowAtLocation < ' tcx , BD , DR >
141+ where
142+ BD : BitDenotation < ' tcx > ,
143+ DR : Borrow < DataflowResults < ' tcx , BD > > ,
139144{
140145 fn reset_to_entry_of ( & mut self , bb : BasicBlock ) {
141- self . curr_state . overwrite ( self . base_results . sets ( ) . entry_set_for ( bb. index ( ) ) ) ;
146+ self . curr_state . overwrite ( self . base_results . borrow ( ) . sets ( ) . entry_set_for ( bb. index ( ) ) ) ;
142147 }
143148
144149 fn reset_to_exit_of ( & mut self , bb : BasicBlock ) {
145150 self . reset_to_entry_of ( bb) ;
146- let trans = self . base_results . sets ( ) . trans_for ( bb. index ( ) ) ;
151+ let trans = self . base_results . borrow ( ) . sets ( ) . trans_for ( bb. index ( ) ) ;
147152 trans. apply ( & mut self . curr_state )
148153 }
149154
150155 fn reconstruct_statement_effect ( & mut self , loc : Location ) {
151156 self . stmt_trans . clear ( ) ;
152157 self . base_results
158+ . borrow ( )
153159 . operator ( )
154160 . before_statement_effect ( & mut self . stmt_trans , loc) ;
155161 self . stmt_trans . apply ( & mut self . curr_state ) ;
156162
157163 self . base_results
164+ . borrow ( )
158165 . operator ( )
159166 . statement_effect ( & mut self . stmt_trans , loc) ;
160167 }
161168
162169 fn reconstruct_terminator_effect ( & mut self , loc : Location ) {
163170 self . stmt_trans . clear ( ) ;
164171 self . base_results
172+ . borrow ( )
165173 . operator ( )
166174 . before_terminator_effect ( & mut self . stmt_trans , loc) ;
167175 self . stmt_trans . apply ( & mut self . curr_state ) ;
168176
169177 self . base_results
178+ . borrow ( )
170179 . operator ( )
171180 . terminator_effect ( & mut self . stmt_trans , loc) ;
172181 }
@@ -177,9 +186,10 @@ impl<'tcx, BD> FlowsAtLocation for FlowAtLocation<'tcx, BD>
177186}
178187
179188
180- impl < ' tcx , T > FlowAtLocation < ' tcx , T >
189+ impl < ' tcx , T , DR > FlowAtLocation < ' tcx , T , DR >
181190where
182191 T : HasMoveData < ' tcx > + BitDenotation < ' tcx , Idx = MovePathIndex > ,
192+ DR : Borrow < DataflowResults < ' tcx , T > > ,
183193{
184194 pub fn has_any_child_of ( & self , mpi : T :: Idx ) -> Option < T :: Idx > {
185195 // We process `mpi` before the loop below, for two reasons:
0 commit comments