Resolve reviews
This commit is contained in:
parent
a3f403aa50
commit
1cee3fe00e
@ -343,7 +343,7 @@ fn bool_expr(&self, e: &'tcx Expr) {
|
|||||||
|
|
||||||
let stats = terminal_stats(&expr);
|
let stats = terminal_stats(&expr);
|
||||||
let mut simplified = expr.simplify();
|
let mut simplified = expr.simplify();
|
||||||
for simple in Bool::Not(Box::new(expr.clone())).simplify() {
|
for simple in Bool::Not(Box::new(expr)).simplify() {
|
||||||
match simple {
|
match simple {
|
||||||
Bool::Not(_) | Bool::True | Bool::False => {},
|
Bool::Not(_) | Bool::True | Bool::False => {},
|
||||||
_ => simplified.push(Bool::Not(Box::new(simple.clone()))),
|
_ => simplified.push(Bool::Not(Box::new(simple.clone()))),
|
||||||
|
@ -137,9 +137,7 @@ fn check_fn(
|
|||||||
statement_index: bbdata.statements.len(),
|
statement_index: bbdata.statements.len(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if from_borrow
|
if from_borrow && (cannot_move_out || !possible_borrower.only_borrowers(&[arg], cloned, loc)) {
|
||||||
&& (cannot_move_out || possible_borrower.only_borrowers(&[arg][..], cloned, loc) != Some(true))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +169,7 @@ fn check_fn(
|
|||||||
block: bb,
|
block: bb,
|
||||||
statement_index: mir.basic_blocks()[bb].statements.len(),
|
statement_index: mir.basic_blocks()[bb].statements.len(),
|
||||||
};
|
};
|
||||||
if cannot_move_out || possible_borrower.only_borrowers(&[arg, cloned][..], local, loc) != Some(true) {
|
if cannot_move_out || !possible_borrower.only_borrowers(&[arg, cloned], local, loc) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
local
|
local
|
||||||
@ -564,22 +562,22 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) {
|
|||||||
struct PossibleBorrower<'a, 'tcx> {
|
struct PossibleBorrower<'a, 'tcx> {
|
||||||
map: FxHashMap<mir::Local, HybridBitSet<mir::Local>>,
|
map: FxHashMap<mir::Local, HybridBitSet<mir::Local>>,
|
||||||
maybe_live: DataflowResultsCursor<'a, 'tcx, MaybeStorageLive<'a, 'tcx>>,
|
maybe_live: DataflowResultsCursor<'a, 'tcx, MaybeStorageLive<'a, 'tcx>>,
|
||||||
|
// Caches to avoid allocation of `BitSet` on every query
|
||||||
bitset: (BitSet<mir::Local>, BitSet<mir::Local>),
|
bitset: (BitSet<mir::Local>, BitSet<mir::Local>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PossibleBorrower<'_, '_> {
|
impl PossibleBorrower<'_, '_> {
|
||||||
fn only_borrowers<'a>(
|
fn only_borrowers(&mut self, borrowers: &[mir::Local], borrowed: mir::Local, at: mir::Location) -> bool {
|
||||||
&mut self,
|
|
||||||
borrowers: impl IntoIterator<Item = &'a mir::Local>,
|
|
||||||
borrowed: mir::Local,
|
|
||||||
at: mir::Location,
|
|
||||||
) -> Option<bool> {
|
|
||||||
self.maybe_live.seek(at);
|
self.maybe_live.seek(at);
|
||||||
|
|
||||||
self.bitset.0.clear();
|
self.bitset.0.clear();
|
||||||
let maybe_live = &mut self.maybe_live;
|
let maybe_live = &mut self.maybe_live;
|
||||||
for b in self.map.get(&borrowed)?.iter().filter(move |b| maybe_live.contains(*b)) {
|
if let Some(bitset) = self.map.get(&borrowed) {
|
||||||
self.bitset.0.insert(b);
|
for b in bitset.iter().filter(move |b| maybe_live.contains(*b)) {
|
||||||
|
self.bitset.0.insert(b);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bitset.1.clear();
|
self.bitset.1.clear();
|
||||||
@ -587,6 +585,6 @@ fn only_borrowers<'a>(
|
|||||||
self.bitset.1.insert(*b);
|
self.bitset.1.insert(*b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(self.bitset.0 == self.bitset.1)
|
self.bitset.0 == self.bitset.1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user