@@ -8,6 +8,7 @@ use crate::dataflow::{BitDenotation, DataflowResults, GenKillSet};
8
8
use crate :: dataflow:: move_paths:: { HasMoveData , MovePathIndex } ;
9
9
10
10
use std:: iter;
11
+ use std:: borrow:: Borrow ;
11
12
12
13
/// A trait for "cartesian products" of multiple FlowAtLocation.
13
14
///
@@ -60,18 +61,20 @@ pub trait FlowsAtLocation {
60
61
/// (e.g., via `reconstruct_statement_effect` and
61
62
/// `reconstruct_terminator_effect`; don't forget to call
62
63
/// `apply_local_effect`).
63
- pub struct FlowAtLocation < ' tcx , BD >
64
+ pub struct FlowAtLocation < ' tcx , BD , DR = DataflowResults < ' tcx , BD > >
64
65
where
65
66
BD : BitDenotation < ' tcx > ,
67
+ DR : Borrow < DataflowResults < ' tcx , BD > > ,
66
68
{
67
- base_results : DataflowResults < ' tcx , BD > ,
69
+ base_results : DR ,
68
70
curr_state : BitSet < BD :: Idx > ,
69
71
stmt_trans : GenKillSet < BD :: Idx > ,
70
72
}
71
73
72
- impl < ' tcx , BD > FlowAtLocation < ' tcx , BD >
74
+ impl < ' tcx , BD , DR > FlowAtLocation < ' tcx , BD , DR >
73
75
where
74
76
BD : BitDenotation < ' tcx > ,
77
+ DR : Borrow < DataflowResults < ' tcx , BD > > ,
75
78
{
76
79
/// Iterate over each bit set in the current state.
77
80
pub fn each_state_bit < F > ( & self , f : F )
91
94
self . stmt_trans . gen_set . iter ( ) . for_each ( f)
92
95
}
93
96
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 ( ) ;
96
99
let curr_state = BitSet :: new_empty ( bits_per_block) ;
97
100
let stmt_trans = GenKillSet :: from_elem ( HybridBitSet :: new_empty ( bits_per_block) ) ;
98
101
FlowAtLocation {
@@ -104,7 +107,7 @@ where
104
107
105
108
/// Access the underlying operator.
106
109
pub fn operator ( & self ) -> & BD {
107
- self . base_results . operator ( )
110
+ self . base_results . borrow ( ) . operator ( )
108
111
}
109
112
110
113
pub fn contains ( & self , x : BD :: Idx ) -> bool {
@@ -134,39 +137,45 @@ where
134
137
}
135
138
}
136
139
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 > > ,
139
144
{
140
145
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 ( ) ) ) ;
142
147
}
143
148
144
149
fn reset_to_exit_of ( & mut self , bb : BasicBlock ) {
145
150
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 ( ) ) ;
147
152
trans. apply ( & mut self . curr_state )
148
153
}
149
154
150
155
fn reconstruct_statement_effect ( & mut self , loc : Location ) {
151
156
self . stmt_trans . clear ( ) ;
152
157
self . base_results
158
+ . borrow ( )
153
159
. operator ( )
154
160
. before_statement_effect ( & mut self . stmt_trans , loc) ;
155
161
self . stmt_trans . apply ( & mut self . curr_state ) ;
156
162
157
163
self . base_results
164
+ . borrow ( )
158
165
. operator ( )
159
166
. statement_effect ( & mut self . stmt_trans , loc) ;
160
167
}
161
168
162
169
fn reconstruct_terminator_effect ( & mut self , loc : Location ) {
163
170
self . stmt_trans . clear ( ) ;
164
171
self . base_results
172
+ . borrow ( )
165
173
. operator ( )
166
174
. before_terminator_effect ( & mut self . stmt_trans , loc) ;
167
175
self . stmt_trans . apply ( & mut self . curr_state ) ;
168
176
169
177
self . base_results
178
+ . borrow ( )
170
179
. operator ( )
171
180
. terminator_effect ( & mut self . stmt_trans , loc) ;
172
181
}
@@ -177,9 +186,10 @@ impl<'tcx, BD> FlowsAtLocation for FlowAtLocation<'tcx, BD>
177
186
}
178
187
179
188
180
- impl < ' tcx , T > FlowAtLocation < ' tcx , T >
189
+ impl < ' tcx , T , DR > FlowAtLocation < ' tcx , T , DR >
181
190
where
182
191
T : HasMoveData < ' tcx > + BitDenotation < ' tcx , Idx = MovePathIndex > ,
192
+ DR : Borrow < DataflowResults < ' tcx , T > > ,
183
193
{
184
194
pub fn has_any_child_of ( & self , mpi : T :: Idx ) -> Option < T :: Idx > {
185
195
// We process `mpi` before the loop below, for two reasons:
0 commit comments