Resolve reviews

This commit is contained in:
Shotaro Yamada 2019-09-28 20:29:35 +09:00
parent a3f403aa50
commit 1cee3fe00e
2 changed files with 12 additions and 14 deletions

View File

@ -343,7 +343,7 @@ fn bool_expr(&self, e: &'tcx Expr) {
let stats = terminal_stats(&expr);
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 {
Bool::Not(_) | Bool::True | Bool::False => {},
_ => simplified.push(Bool::Not(Box::new(simple.clone()))),

View File

@ -137,9 +137,7 @@ fn check_fn(
statement_index: bbdata.statements.len(),
};
if from_borrow
&& (cannot_move_out || possible_borrower.only_borrowers(&[arg][..], cloned, loc) != Some(true))
{
if from_borrow && (cannot_move_out || !possible_borrower.only_borrowers(&[arg], cloned, loc)) {
continue;
}
@ -171,7 +169,7 @@ fn check_fn(
block: bb,
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;
}
local
@ -564,22 +562,22 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) {
struct PossibleBorrower<'a, 'tcx> {
map: FxHashMap<mir::Local, HybridBitSet<mir::Local>>,
maybe_live: DataflowResultsCursor<'a, 'tcx, MaybeStorageLive<'a, 'tcx>>,
// Caches to avoid allocation of `BitSet` on every query
bitset: (BitSet<mir::Local>, BitSet<mir::Local>),
}
impl PossibleBorrower<'_, '_> {
fn only_borrowers<'a>(
&mut self,
borrowers: impl IntoIterator<Item = &'a mir::Local>,
borrowed: mir::Local,
at: mir::Location,
) -> Option<bool> {
fn only_borrowers(&mut self, borrowers: &[mir::Local], borrowed: mir::Local, at: mir::Location) -> bool {
self.maybe_live.seek(at);
self.bitset.0.clear();
let maybe_live = &mut self.maybe_live;
for b in self.map.get(&borrowed)?.iter().filter(move |b| maybe_live.contains(*b)) {
self.bitset.0.insert(b);
if let Some(bitset) = self.map.get(&borrowed) {
for b in bitset.iter().filter(move |b| maybe_live.contains(*b)) {
self.bitset.0.insert(b);
}
} else {
return false;
}
self.bitset.1.clear();
@ -587,6 +585,6 @@ fn only_borrowers<'a>(
self.bitset.1.insert(*b);
}
Some(self.bitset.0 == self.bitset.1)
self.bitset.0 == self.bitset.1
}
}