Skip to content

Commit 01866a0

Browse files
committed
renumber: debug logs, use visit_region rather than visit_rvalue
1 parent 2a59a53 commit 01866a0

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

src/librustc_mir/transform/nll/renumber.rs

+29-22
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
1212
use rustc::ty::subst::Substs;
1313
use rustc::ty::{self, ClosureSubsts, RegionVid, Ty, TypeFoldable};
14-
use rustc::mir::{BasicBlock, Local, Location, Mir, Rvalue, Statement, StatementKind};
14+
use rustc::mir::{BasicBlock, Local, Location, Mir, Statement, StatementKind};
1515
use rustc::mir::visit::{MutVisitor, TyContext};
1616
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
1717

@@ -36,6 +36,10 @@ pub fn renumber_mir<'a, 'gcx, 'tcx>(
3636
})
3737
.collect();
3838

39+
debug!("renumber_mir()");
40+
debug!("renumber_mir: free_regions={:#?}", free_regions);
41+
debug!("renumber_mir: mir.arg_count={:?}", mir.arg_count);
42+
3943
let mut visitor = NLLVisitor {
4044
infcx,
4145
free_regions,
@@ -60,6 +64,8 @@ impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
6064
where
6165
T: TypeFoldable<'tcx>,
6266
{
67+
debug!("renumber_regions(value={:?})", value);
68+
6369
self.infcx
6470
.tcx
6571
.fold_regions(value, &mut false, |_region, _depth| {
@@ -74,6 +80,8 @@ impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
7480
where
7581
T: TypeFoldable<'tcx>,
7682
{
83+
debug!("renumber_free_regions(value={:?})", value);
84+
7785
self.infcx
7886
.tcx
7987
.fold_regions(value, &mut false, |region, _depth| {
@@ -112,36 +120,35 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
112120
}
113121

114122
fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) {
123+
debug!("visit_substs(substs={:?}, location={:?})", substs, location);
124+
115125
let ty_context = TyContext::Location(location);
116126
*substs = self.renumber_regions(ty_context, &{ *substs });
127+
128+
debug!("visit_substs: substs={:?}", substs);
117129
}
118130

119-
fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location) {
120-
match *rvalue {
121-
Rvalue::Ref(ref mut r, _, _) => {
122-
let old_r = *r;
123-
let ty_context = TyContext::Location(location);
124-
*r = self.renumber_regions(ty_context, &old_r);
125-
}
126-
Rvalue::Use(..) |
127-
Rvalue::Repeat(..) |
128-
Rvalue::Len(..) |
129-
Rvalue::Cast(..) |
130-
Rvalue::BinaryOp(..) |
131-
Rvalue::CheckedBinaryOp(..) |
132-
Rvalue::UnaryOp(..) |
133-
Rvalue::Discriminant(..) |
134-
Rvalue::NullaryOp(..) |
135-
Rvalue::Aggregate(..) => {
136-
// These variants don't contain regions.
137-
}
138-
}
139-
self.super_rvalue(rvalue, location);
131+
fn visit_region(&mut self, region: &mut ty::Region<'tcx>, location: Location) {
132+
debug!("visit_region(region={:?}, location={:?})", region, location);
133+
134+
let old_region = *region;
135+
let ty_context = TyContext::Location(location);
136+
*region = self.renumber_regions(ty_context, &old_region);
137+
138+
debug!("visit_region: region={:?}", region);
140139
}
141140

142141
fn visit_closure_substs(&mut self, substs: &mut ClosureSubsts<'tcx>, location: Location) {
142+
debug!(
143+
"visit_closure_substs(substs={:?}, location={:?})",
144+
substs,
145+
location
146+
);
147+
143148
let ty_context = TyContext::Location(location);
144149
*substs = self.renumber_regions(ty_context, substs);
150+
151+
debug!("visit_closure_substs: substs={:?}", substs);
145152
}
146153

147154
fn visit_statement(

0 commit comments

Comments
 (0)