@@ -11,7 +11,6 @@ use rustc_mir_dataflow::{
11
11
fmt:: DebugWithContext , impls:: MaybeStorageLive , lattice:: JoinSemiLattice , Analysis , AnalysisDomain ,
12
12
CallReturnPlaces , ResultsCursor ,
13
13
} ;
14
- use std:: collections:: VecDeque ;
15
14
use std:: ops:: ControlFlow ;
16
15
17
16
/// Collects the possible borrowers of each local.
@@ -216,6 +215,8 @@ pub struct PossibleBorrowerMap<'b, 'tcx> {
216
215
body : & ' b mir:: Body < ' tcx > ,
217
216
possible_borrower : ResultsCursor < ' b , ' tcx , PossibleBorrowerAnalysis < ' b , ' tcx > > ,
218
217
maybe_live : ResultsCursor < ' b , ' tcx , MaybeStorageLive > ,
218
+ pushed : BitSet < Local > ,
219
+ stack : Vec < Local > ,
219
220
}
220
221
221
222
impl < ' b , ' tcx > PossibleBorrowerMap < ' b , ' tcx > {
@@ -239,6 +240,8 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
239
240
body : mir,
240
241
possible_borrower,
241
242
maybe_live,
243
+ pushed : BitSet :: new_empty ( mir. local_decls . len ( ) ) ,
244
+ stack : Vec :: with_capacity ( mir. local_decls . len ( ) ) ,
242
245
}
243
246
}
244
247
@@ -269,29 +272,29 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
269
272
let possible_borrower = & self . possible_borrower . get ( ) . map ;
270
273
let maybe_live = & self . maybe_live ;
271
274
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 ( ) ;
274
277
275
278
if let Some ( borrowers) = possible_borrower. get ( & borrowed) {
276
279
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) ;
279
282
}
280
283
}
281
284
} else {
282
285
// Nothing borrows `borrowed` at `at`.
283
286
return true ;
284
287
}
285
288
286
- while let Some ( borrower) = deque . pop_front ( ) {
289
+ while let Some ( borrower) = self . stack . pop ( ) {
287
290
if maybe_live. contains ( borrower) && !borrowers. contains ( & borrower) {
288
291
return false ;
289
292
}
290
293
291
294
if let Some ( borrowers) = possible_borrower. get ( & borrower) {
292
295
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) ;
295
298
}
296
299
}
297
300
}
0 commit comments