Skip to content

Commit 4b44db1

Browse files
committed
each_affected_by_dirty
1 parent 9bd2a63 commit 4b44db1

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/librustc_mir/borrow_check/nll/constraint_set.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
12-
use rustc_data_structures::fx::FxHashSet;
13-
use rustc::ty::RegionVid;
1411
use rustc::mir::Location;
12+
use rustc::ty::RegionVid;
13+
use rustc_data_structures::fx::FxHashSet;
14+
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
1515

1616
use std::fmt;
1717
use syntax_pos::Span;
@@ -23,15 +23,11 @@ crate struct ConstraintSet {
2323
}
2424

2525
impl ConstraintSet {
26-
pub fn new() -> Self {
27-
Default::default()
28-
}
29-
3026
pub fn push(&mut self, constraint: OutlivesConstraint) {
31-
debug!("add_outlives({:?}: {:?} @ {:?}",
32-
constraint.sup,
33-
constraint.sub,
34-
constraint.point);
27+
debug!(
28+
"add_outlives({:?}: {:?} @ {:?}",
29+
constraint.sup, constraint.sub, constraint.point
30+
);
3531
if constraint.sup == constraint.sub {
3632
// 'a: 'a is pretty uninteresting
3733
return;
@@ -57,6 +53,17 @@ impl ConstraintSet {
5753

5854
map
5955
}
56+
57+
pub fn each_affected_by_dirty(
58+
&self,
59+
mut opt_dep_idx: Option<ConstraintIndex>,
60+
mut op: impl FnMut(ConstraintIndex),
61+
) {
62+
while let Some(dep_idx) = opt_dep_idx {
63+
op(dep_idx);
64+
opt_dep_idx = self.constraints[dep_idx].next;
65+
}
66+
}
6067
}
6168

6269
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -105,4 +112,3 @@ impl fmt::Debug for OutlivesConstraint {
105112
}
106113

107114
newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });
108-

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
466466
debug!("propagate_constraints: sub={:?}", constraint.sub);
467467
debug!("propagate_constraints: sup={:?}", constraint.sup);
468468

469-
let mut opt_dep_idx = dependency_map[constraint.sup];
470-
while let Some(dep_idx) = opt_dep_idx {
469+
self.constraints.each_affected_by_dirty(dependency_map[constraint.sup], |dep_idx| {
471470
if clean_bit_vec.remove(dep_idx.index()) {
472471
dirty_list.push(dep_idx);
473472
}
474-
opt_dep_idx = self.constraints.inner()[dep_idx].next;
475-
}
473+
});
476474
}
477475

478476
debug!("\n");

0 commit comments

Comments
 (0)