提交 32f964cc 编写于 作者: N Niko Matsakis

renumber: debug logs, use `visit_region` rather than `visit_rvalue`

上级 12534e91
......@@ -11,7 +11,7 @@
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};
......@@ -36,6 +36,10 @@ pub fn renumber_mir<'a, 'gcx, 'tcx>(
})
.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,
......@@ -60,6 +64,8 @@ fn renumber_regions<T>(&mut self, ty_context: TyContext, value: &T) -> T
where
T: TypeFoldable<'tcx>,
{
debug!("renumber_regions(value={:?})", value);
self.infcx
.tcx
.fold_regions(value, &mut false, |_region, _depth| {
......@@ -74,6 +80,8 @@ fn renumber_free_regions<T>(&mut self, value: &T) -> T
where
T: TypeFoldable<'tcx>,
{
debug!("renumber_free_regions(value={:?})", value);
self.infcx
.tcx
.fold_regions(value, &mut false, |region, _depth| {
......@@ -112,36 +120,35 @@ fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
}
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(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册