@@ -11,7 +11,6 @@ use rustc_mir_dataflow::{
1111 fmt:: DebugWithContext , impls:: MaybeStorageLive , lattice:: JoinSemiLattice , Analysis , AnalysisDomain ,
1212 CallReturnPlaces , ResultsCursor ,
1313} ;
14- use std:: collections:: VecDeque ;
1514use std:: ops:: ControlFlow ;
1615
1716/// Collects the possible borrowers of each local.
@@ -216,6 +215,8 @@ pub struct PossibleBorrowerMap<'b, 'tcx> {
216215 body : & ' b mir:: Body < ' tcx > ,
217216 possible_borrower : ResultsCursor < ' b , ' tcx , PossibleBorrowerAnalysis < ' b , ' tcx > > ,
218217 maybe_live : ResultsCursor < ' b , ' tcx , MaybeStorageLive > ,
218+ pushed : BitSet < Local > ,
219+ stack : Vec < Local > ,
219220}
220221
221222impl < ' b , ' tcx > PossibleBorrowerMap < ' b , ' tcx > {
@@ -239,6 +240,8 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
239240 body : mir,
240241 possible_borrower,
241242 maybe_live,
243+ pushed : BitSet :: new_empty ( mir. local_decls . len ( ) ) ,
244+ stack : Vec :: with_capacity ( mir. local_decls . len ( ) ) ,
242245 }
243246 }
244247
@@ -269,29 +272,29 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
269272 let possible_borrower = & self . possible_borrower . get ( ) . map ;
270273 let maybe_live = & self . maybe_live ;
271274
272- let mut queued = BitSet :: new_empty ( self . body . local_decls . len ( ) ) ;
273- let mut deque = VecDeque :: with_capacity ( self . body . local_decls . len ( ) ) ;
275+ self . pushed . clear ( ) ;
276+ self . stack . clear ( ) ;
274277
275278 if let Some ( borrowers) = possible_borrower. get ( & borrowed) {
276279 for b in borrowers. iter ( ) {
277- if queued . insert ( b) {
278- deque . push_back ( b) ;
280+ if self . pushed . insert ( b) {
281+ self . stack . push ( b) ;
279282 }
280283 }
281284 } else {
282285 // Nothing borrows `borrowed` at `at`.
283286 return true ;
284287 }
285288
286- while let Some ( borrower) = deque . pop_front ( ) {
289+ while let Some ( borrower) = self . stack . pop ( ) {
287290 if maybe_live. contains ( borrower) && !borrowers. contains ( & borrower) {
288291 return false ;
289292 }
290293
291294 if let Some ( borrowers) = possible_borrower. get ( & borrower) {
292295 for b in borrowers. iter ( ) {
293- if queued . insert ( b) {
294- deque . push_back ( b) ;
296+ if self . pushed . insert ( b) {
297+ self . stack . push ( b) ;
295298 }
296299 }
297300 }
0 commit comments