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> { 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 { pub fn must_hold(&self) -> bool {
match self { match self {
&VerifyBound::AnyRegion(ref bs) => bs.contains(&&ty::ReStatic), &VerifyBound::AnyRegion(ref bs) => bs.contains(&&ty::ReStatic),

View file

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