use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc::ty::subst::Substs;
use rustc::ty::{self, ClosureSubsts, RegionVid, Ty, TypeFoldable};
-use rustc::mir::{BasicBlock, Local, Location, Mir, Rvalue, Statement, StatementKind};
+use rustc::mir::{BasicBlock, Local, Location, Mir, Statement, StatementKind};
use rustc::mir::visit::{MutVisitor, TyContext};
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
})
.collect();
+ debug!("renumber_mir()");
+ debug!("renumber_mir: free_regions={:#?}", free_regions);
+ debug!("renumber_mir: mir.arg_count={:?}", mir.arg_count);
+
let mut visitor = NLLVisitor {
infcx,
free_regions,
where
T: TypeFoldable<'tcx>,
{
+ debug!("renumber_regions(value={:?})", value);
+
self.infcx
.tcx
.fold_regions(value, &mut false, |_region, _depth| {
where
T: TypeFoldable<'tcx>,
{
+ debug!("renumber_free_regions(value={:?})", value);
+
self.infcx
.tcx
.fold_regions(value, &mut false, |region, _depth| {
}
fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) {
+ debug!("visit_substs(substs={:?}, location={:?})", substs, location);
+
let ty_context = TyContext::Location(location);
*substs = self.renumber_regions(ty_context, &{ *substs });
+
+ debug!("visit_substs: substs={:?}", substs);
}
- fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location) {
- match *rvalue {
- Rvalue::Ref(ref mut r, _, _) => {
- let old_r = *r;
- let ty_context = TyContext::Location(location);
- *r = self.renumber_regions(ty_context, &old_r);
- }
- Rvalue::Use(..) |
- Rvalue::Repeat(..) |
- Rvalue::Len(..) |
- Rvalue::Cast(..) |
- Rvalue::BinaryOp(..) |
- Rvalue::CheckedBinaryOp(..) |
- Rvalue::UnaryOp(..) |
- Rvalue::Discriminant(..) |
- Rvalue::NullaryOp(..) |
- Rvalue::Aggregate(..) => {
- // These variants don't contain regions.
- }
- }
- self.super_rvalue(rvalue, location);
+ fn visit_region(&mut self, region: &mut ty::Region<'tcx>, location: Location) {
+ debug!("visit_region(region={:?}, location={:?})", region, location);
+
+ let old_region = *region;
+ let ty_context = TyContext::Location(location);
+ *region = self.renumber_regions(ty_context, &old_region);
+
+ debug!("visit_region: region={:?}", region);
}
fn visit_closure_substs(&mut self, substs: &mut ClosureSubsts<'tcx>, location: Location) {
+ debug!(
+ "visit_closure_substs(substs={:?}, location={:?})",
+ substs,
+ location
+ );
+
let ty_context = TyContext::Location(location);
*substs = self.renumber_regions(ty_context, substs);
+
+ debug!("visit_closure_substs: substs={:?}", substs);
}
fn visit_statement(