1
Fork 0

remove handling of verify from taintset

This lets us remove `for_each_region` and makes things simpler.
This commit is contained in:
Niko Matsakis 2018-09-19 12:44:38 -04:00
parent b5469c5fd7
commit 85d12e2f0b
2 changed files with 25 additions and 37 deletions

View file

@ -882,18 +882,6 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
}
impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
fn for_each_region(&self, f: &mut dyn FnMut(ty::Region<'tcx>)) {
match self {
&VerifyBound::AnyRegion(ref rs) | &VerifyBound::AllRegions(ref rs) => for &r in rs {
f(r);
},
&VerifyBound::AnyBound(ref bs) | &VerifyBound::AllBounds(ref bs) => for b in bs {
b.for_each_region(f);
},
}
}
pub fn must_hold(&self) -> bool {
match self {
&VerifyBound::AnyRegion(ref bs) => bs.contains(&&ty::ReStatic),

View file

@ -13,34 +13,39 @@ use super::*;
#[derive(Debug)]
pub(super) struct TaintSet<'tcx> {
directions: TaintDirections,
regions: FxHashSet<ty::Region<'tcx>>
regions: FxHashSet<ty::Region<'tcx>>,
}
impl<'tcx> TaintSet<'tcx> {
pub(super) fn new(directions: TaintDirections,
initial_region: ty::Region<'tcx>)
-> Self {
pub(super) fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self {
let mut regions = FxHashSet();
regions.insert(initial_region);
TaintSet { directions: directions, regions: regions }
TaintSet {
directions: directions,
regions: regions,
}
}
pub(super) fn fixed_point(&mut self,
tcx: TyCtxt<'_, '_, 'tcx>,
undo_log: &[UndoLogEntry<'tcx>],
verifys: &[Verify<'tcx>]) {
pub(super) fn fixed_point(
&mut self,
tcx: TyCtxt<'_, '_, 'tcx>,
undo_log: &[UndoLogEntry<'tcx>],
verifys: &[Verify<'tcx>],
) {
let mut prev_len = 0;
while prev_len < self.len() {
debug!("tainted: prev_len = {:?} new_len = {:?}",
prev_len, self.len());
debug!(
"tainted: prev_len = {:?} new_len = {:?}",
prev_len,
self.len()
);
prev_len = self.len();
for undo_entry in undo_log {
match undo_entry {
&AddConstraint(Constraint::VarSubVar(a, b)) => {
self.add_edge(tcx.mk_region(ReVar(a)),
tcx.mk_region(ReVar(b)));
self.add_edge(tcx.mk_region(ReVar(a)), tcx.mk_region(ReVar(b)));
}
&AddConstraint(Constraint::RegSubVar(a, b)) => {
self.add_edge(a, tcx.mk_region(ReVar(b)));
@ -55,15 +60,13 @@ impl<'tcx> TaintSet<'tcx> {
self.add_edge(a, tcx.mk_region(ReVar(b)));
}
&AddVerify(i) => {
verifys[i].bound.for_each_region(&mut |b| {
self.add_edge(verifys[i].region, b);
});
span_bug!(
verifys[i].origin.span(),
"we never add verifications while doing higher-ranked things",
)
}
&Purged |
&AddCombination(..) |
&AddVar(..) |
&OpenSnapshot |
&CommitedSnapshot => {}
&Purged | &AddCombination(..) | &AddVar(..) | &OpenSnapshot
| &CommitedSnapshot => {}
}
}
}
@ -77,9 +80,7 @@ impl<'tcx> TaintSet<'tcx> {
self.regions.len()
}
fn add_edge(&mut self,
source: ty::Region<'tcx>,
target: ty::Region<'tcx>) {
fn add_edge(&mut self, source: ty::Region<'tcx>, target: ty::Region<'tcx>) {
if self.directions.incoming {
if self.regions.contains(&target) {
self.regions.insert(source);
@ -93,4 +94,3 @@ impl<'tcx> TaintSet<'tcx> {
}
}
}