Skip to content

Commit 85d12e2

Browse files
committed
remove handling of verify from taintset
This lets us remove `for_each_region` and makes things simpler.
1 parent b5469c5 commit 85d12e2

File tree

2 files changed

+25
-37
lines changed

2 files changed

+25
-37
lines changed

src/librustc/infer/region_constraints/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -882,18 +882,6 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
882882
}
883883

884884
impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
885-
fn for_each_region(&self, f: &mut dyn FnMut(ty::Region<'tcx>)) {
886-
match self {
887-
&VerifyBound::AnyRegion(ref rs) | &VerifyBound::AllRegions(ref rs) => for &r in rs {
888-
f(r);
889-
},
890-
891-
&VerifyBound::AnyBound(ref bs) | &VerifyBound::AllBounds(ref bs) => for b in bs {
892-
b.for_each_region(f);
893-
},
894-
}
895-
}
896-
897885
pub fn must_hold(&self) -> bool {
898886
match self {
899887
&VerifyBound::AnyRegion(ref bs) => bs.contains(&&ty::ReStatic),

src/librustc/infer/region_constraints/taint.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,39 @@ use super::*;
1313
#[derive(Debug)]
1414
pub(super) struct TaintSet<'tcx> {
1515
directions: TaintDirections,
16-
regions: FxHashSet<ty::Region<'tcx>>
16+
regions: FxHashSet<ty::Region<'tcx>>,
1717
}
1818

1919
impl<'tcx> TaintSet<'tcx> {
20-
pub(super) fn new(directions: TaintDirections,
21-
initial_region: ty::Region<'tcx>)
22-
-> Self {
20+
pub(super) fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self {
2321
let mut regions = FxHashSet();
2422
regions.insert(initial_region);
25-
TaintSet { directions: directions, regions: regions }
23+
TaintSet {
24+
directions: directions,
25+
regions: regions,
26+
}
2627
}
2728

28-
pub(super) fn fixed_point(&mut self,
29-
tcx: TyCtxt<'_, '_, 'tcx>,
30-
undo_log: &[UndoLogEntry<'tcx>],
31-
verifys: &[Verify<'tcx>]) {
29+
pub(super) fn fixed_point(
30+
&mut self,
31+
tcx: TyCtxt<'_, '_, 'tcx>,
32+
undo_log: &[UndoLogEntry<'tcx>],
33+
verifys: &[Verify<'tcx>],
34+
) {
3235
let mut prev_len = 0;
3336
while prev_len < self.len() {
34-
debug!("tainted: prev_len = {:?} new_len = {:?}",
35-
prev_len, self.len());
37+
debug!(
38+
"tainted: prev_len = {:?} new_len = {:?}",
39+
prev_len,
40+
self.len()
41+
);
3642

3743
prev_len = self.len();
3844

3945
for undo_entry in undo_log {
4046
match undo_entry {
4147
&AddConstraint(Constraint::VarSubVar(a, b)) => {
42-
self.add_edge(tcx.mk_region(ReVar(a)),
43-
tcx.mk_region(ReVar(b)));
48+
self.add_edge(tcx.mk_region(ReVar(a)), tcx.mk_region(ReVar(b)));
4449
}
4550
&AddConstraint(Constraint::RegSubVar(a, b)) => {
4651
self.add_edge(a, tcx.mk_region(ReVar(b)));
@@ -55,15 +60,13 @@ impl<'tcx> TaintSet<'tcx> {
5560
self.add_edge(a, tcx.mk_region(ReVar(b)));
5661
}
5762
&AddVerify(i) => {
58-
verifys[i].bound.for_each_region(&mut |b| {
59-
self.add_edge(verifys[i].region, b);
60-
});
63+
span_bug!(
64+
verifys[i].origin.span(),
65+
"we never add verifications while doing higher-ranked things",
66+
)
6167
}
62-
&Purged |
63-
&AddCombination(..) |
64-
&AddVar(..) |
65-
&OpenSnapshot |
66-
&CommitedSnapshot => {}
68+
&Purged | &AddCombination(..) | &AddVar(..) | &OpenSnapshot
69+
| &CommitedSnapshot => {}
6770
}
6871
}
6972
}
@@ -77,9 +80,7 @@ impl<'tcx> TaintSet<'tcx> {
7780
self.regions.len()
7881
}
7982

80-
fn add_edge(&mut self,
81-
source: ty::Region<'tcx>,
82-
target: ty::Region<'tcx>) {
83+
fn add_edge(&mut self, source: ty::Region<'tcx>, target: ty::Region<'tcx>) {
8384
if self.directions.incoming {
8485
if self.regions.contains(&target) {
8586
self.regions.insert(source);
@@ -93,4 +94,3 @@ impl<'tcx> TaintSet<'tcx> {
9394
}
9495
}
9596
}
96-

0 commit comments

Comments
 (0)