mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
Address review comments
This commit is contained in:
parent
26df55112f
commit
c7dc961558
1 changed files with 11 additions and 8 deletions
|
@ -11,7 +11,6 @@ use rustc_mir_dataflow::{
|
|||
fmt::DebugWithContext, impls::MaybeStorageLive, lattice::JoinSemiLattice, Analysis, AnalysisDomain,
|
||||
CallReturnPlaces, ResultsCursor,
|
||||
};
|
||||
use std::collections::VecDeque;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
/// Collects the possible borrowers of each local.
|
||||
|
@ -216,6 +215,8 @@ pub struct PossibleBorrowerMap<'b, 'tcx> {
|
|||
body: &'b mir::Body<'tcx>,
|
||||
possible_borrower: ResultsCursor<'b, 'tcx, PossibleBorrowerAnalysis<'b, 'tcx>>,
|
||||
maybe_live: ResultsCursor<'b, 'tcx, MaybeStorageLive>,
|
||||
pushed: BitSet<Local>,
|
||||
stack: Vec<Local>,
|
||||
}
|
||||
|
||||
impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
|
||||
|
@ -239,6 +240,8 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
|
|||
body: mir,
|
||||
possible_borrower,
|
||||
maybe_live,
|
||||
pushed: BitSet::new_empty(mir.local_decls.len()),
|
||||
stack: Vec::with_capacity(mir.local_decls.len()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,13 +272,13 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
|
|||
let possible_borrower = &self.possible_borrower.get().map;
|
||||
let maybe_live = &self.maybe_live;
|
||||
|
||||
let mut queued = BitSet::new_empty(self.body.local_decls.len());
|
||||
let mut deque = VecDeque::with_capacity(self.body.local_decls.len());
|
||||
self.pushed.clear();
|
||||
self.stack.clear();
|
||||
|
||||
if let Some(borrowers) = possible_borrower.get(&borrowed) {
|
||||
for b in borrowers.iter() {
|
||||
if queued.insert(b) {
|
||||
deque.push_back(b);
|
||||
if self.pushed.insert(b) {
|
||||
self.stack.push(b);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -283,15 +286,15 @@ impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> {
|
|||
return true;
|
||||
}
|
||||
|
||||
while let Some(borrower) = deque.pop_front() {
|
||||
while let Some(borrower) = self.stack.pop() {
|
||||
if maybe_live.contains(borrower) && !borrowers.contains(&borrower) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(borrowers) = possible_borrower.get(&borrower) {
|
||||
for b in borrowers.iter() {
|
||||
if queued.insert(b) {
|
||||
deque.push_back(b);
|
||||
if self.pushed.insert(b) {
|
||||
self.stack.push(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue