]> git.lizzy.rs Git - rust.git/commitdiff
Run the analysis process only once per closure, on the way up the tree.
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 17 Jul 2015 12:20:23 +0000 (08:20 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 24 Jul 2015 08:53:19 +0000 (04:53 -0400)
This was the intention before but silly coding caused it to run twice if
there are nested closures.

src/librustc_typeck/check/upvar.rs

index c7f084e27cda015f456bec5d6d0906b2b445bcf1..20db3b69bd15e212033f763e9b46b1980995674f 100644 (file)
@@ -183,9 +183,8 @@ fn analyze_closure(&mut self, id: ast::NodeId, decl: &ast::FnDecl, body: &ast::B
          * Analysis starting point.
          */
 
-        self.visit_block(body);
+        debug!("analyze_closure(id={:?}, body.id={:?})", id, body.id);
 
-        debug!("analyzing closure `{}` with fn body id `{}`", id, body.id);
 
         let mut euv = euv::ExprUseVisitor::new(self, self.fcx.infcx());
         euv.walk_fn(decl, body);
@@ -485,8 +484,8 @@ fn visit_fn(&mut self,
                 // ignore nested fn items
             }
             visit::FkFnBlock => {
-                self.analyze_closure(id, decl, body);
                 visit::walk_fn(self, fn_kind, decl, body, span);
+                self.analyze_closure(id, span, decl, body);
             }
         }
     }