each_affected_by_dirty

This commit is contained in:
Eh2406 2018-06-27 18:15:57 -04:00
parent 9bd2a63f29
commit 4b44db126e
2 changed files with 20 additions and 16 deletions

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_data_structures::fx::FxHashSet;
use rustc::ty::RegionVid;
use rustc::mir::Location;
use rustc::ty::RegionVid;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use std::fmt;
use syntax_pos::Span;
@ -23,15 +23,11 @@ crate struct ConstraintSet {
}
impl ConstraintSet {
pub fn new() -> Self {
Default::default()
}
pub fn push(&mut self, constraint: OutlivesConstraint) {
debug!("add_outlives({:?}: {:?} @ {:?}",
constraint.sup,
constraint.sub,
constraint.point);
debug!(
"add_outlives({:?}: {:?} @ {:?}",
constraint.sup, constraint.sub, constraint.point
);
if constraint.sup == constraint.sub {
// 'a: 'a is pretty uninteresting
return;
@ -57,6 +53,17 @@ impl ConstraintSet {
map
}
pub fn each_affected_by_dirty(
&self,
mut opt_dep_idx: Option<ConstraintIndex>,
mut op: impl FnMut(ConstraintIndex),
) {
while let Some(dep_idx) = opt_dep_idx {
op(dep_idx);
opt_dep_idx = self.constraints[dep_idx].next;
}
}
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@ -105,4 +112,3 @@ impl fmt::Debug for OutlivesConstraint {
}
newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });

View File

@ -466,13 +466,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
debug!("propagate_constraints: sub={:?}", constraint.sub);
debug!("propagate_constraints: sup={:?}", constraint.sup);
let mut opt_dep_idx = dependency_map[constraint.sup];
while let Some(dep_idx) = opt_dep_idx {
self.constraints.each_affected_by_dirty(dependency_map[constraint.sup], |dep_idx| {
if clean_bit_vec.remove(dep_idx.index()) {
dirty_list.push(dep_idx);
}
opt_dep_idx = self.constraints.inner()[dep_idx].next;
}
});
}
debug!("\n");