Store a new Region value every time we create a new region variable

This commit is contained in:
Paul Faria
2017-09-26 22:24:19 -04:00
committed by Santiago Pastorino
parent d7e73e4b1a
commit 0c5de8633c
+11 -2
View File
@@ -15,12 +15,14 @@
use rustc::mir::visit::{MutVisitor, Lookup};
use rustc::mir::transform::{MirPass, MirSource};
use rustc::infer::{self, InferCtxt};
use rustc::util::nodemap::FxHashSet;
use syntax_pos::DUMMY_SP;
use std::collections::HashMap;
#[allow(dead_code)]
struct NLLVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
lookup_map: HashMap<RegionVid, Lookup>,
regions: Vec<Region>,
infcx: InferCtxt<'a, 'gcx, 'tcx>,
}
@@ -29,6 +31,7 @@ pub fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>) -> Self {
NLLVisitor {
infcx,
lookup_map: HashMap::new(),
regions: vec![],
}
}
@@ -36,8 +39,9 @@ pub fn into_results(self) -> HashMap<RegionVid, Lookup> {
self.lookup_map
}
fn renumber_regions<T>(&self, value: &T) -> T where T: TypeFoldable<'tcx> {
fn renumber_regions<T>(&mut self, value: &T) -> T where T: TypeFoldable<'tcx> {
self.infcx.tcx.fold_regions(value, &mut false, |_region, _depth| {
self.regions.push(Region::default());
self.infcx.next_region_var(infer::MiscVariable(DUMMY_SP))
})
}
@@ -143,4 +147,9 @@ fn run_pass<'a, 'tcx>(&self,
let _results = visitor.into_results();
})
}
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
struct Region {
points: FxHashSet<Location>,
}