]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/borrow_check/nll/renumber.rs
Fix tidy
[rust.git] / src / librustc_mir / borrow_check / nll / renumber.rs
index c1d1185cf177ad7fa4461cad12d263ffdcf30b08..c6a5c6fdfd0f21661e4304f897c0bb1886538273 100644 (file)
@@ -1,16 +1,22 @@
 use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable};
-use rustc::mir::{Location, Body};
+use rustc::mir::{Location, Body, Promoted};
 use rustc::mir::visit::{MutVisitor, TyContext};
 use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
+use rustc_data_structures::indexed_vec::IndexVec;
 
 /// Replaces all free regions appearing in the MIR with fresh
 /// inference variables, returning the number of variables created.
-pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, 'tcx>, body: &mut Body<'tcx>) {
+pub fn renumber_mir<'tcx>(
+    infcx: &InferCtxt<'_, 'tcx>,
+    body: &mut Body<'tcx>,
+    promoted: &mut IndexVec<Promoted, Body<'tcx>>,
+) {
     debug!("renumber_mir()");
     debug!("renumber_mir: body.arg_count={:?}", body.arg_count);
 
     let mut visitor = NLLVisitor { infcx };
+    visitor.visit_promoted(promoted);
     visitor.visit_body(body);
 }
 
@@ -41,17 +47,16 @@ fn renumber_regions<T>(&mut self, value: &T) -> T
     {
         renumber_regions(self.infcx, value)
     }
-}
 
-impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> {
-    fn visit_body(&mut self, body: &mut Body<'tcx>) {
-        for promoted in body.promoted.iter_mut() {
-            self.visit_body(promoted);
+    fn visit_promoted(&mut self, promoted: &mut IndexVec<Promoted, Body<'tcx>>) {
+        debug!("visiting promoted mir");
+        for body in promoted.iter_mut() {
+            self.visit_body(body);
         }
-
-        self.super_body(body);
     }
+}
 
+impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> {
     fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
         debug!("visit_ty(ty={:?}, ty_context={:?})", ty, ty_context);