about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-06-23 20:22:02 -0400
committerAaron Hill <aa1ronham@gmail.com>2019-06-23 20:23:07 -0400
commit770655a47f9577b15e499a76f87b903bbde93c3b (patch)
tree565323b8f489b6237e436136ca1544fa7c87e684 /src
parente3d8001f00380bcce64a79fae8c165d21cfc30ed (diff)
downloadrust-770655a47f9577b15e499a76f87b903bbde93c3b.tar.gz
rust-770655a47f9577b15e499a76f87b903bbde93c3b.zip
Replace Vec<Vec<_>> with Vec<_>
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/region.rs27
-rw-r--r--src/librustc_typeck/check/generator_interior.rs2
2 files changed, 9 insertions, 20 deletions
diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs
index c43a375c567..114684b1524 100644
--- a/src/librustc/middle/region.rs
+++ b/src/librustc/middle/region.rs
@@ -376,15 +376,7 @@ struct RegionResolutionVisitor<'tcx> {
     // up their indices.
     pessimistic_yield: bool,
     // Stores scopes when pessimistic_yield is true.
-    // Each time we encounter an ExprKind::AssignOp, we push
-    // a new Vec into the outermost Vec. This inner Vec is used
-    // to store any scopes we encounter when visiting the inner expressions
-    // of the AssignOp. Once we finish visiting the inner expressions, we pop
-    // off the inner Vec, and process the Scopes it contains.
-    // This allows us to handle nested AssignOps - while a terrible idea,
-    // they are valid Rust, so we need to handle them.
-    fixup_scopes: Vec<Vec<Scope>>,
-
+    fixup_scopes: Vec<Scope>,
     // Generated scope tree:
     scope_tree: ScopeTree,
 
@@ -1020,11 +1012,11 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
             let body = visitor.tcx.hir().body(body);
             visitor.visit_body(body);
         },
-        hir::ExprKind::AssignOp(_, ref left_expression, ref right_expression) => {
+        hir::ExprKind::AssignOp(_, ref left_expr, ref right_expr) => {
             debug!("resolve_expr - enabling pessimistic_yield, was previously {}",
                    prev_pessimistic);
 
-            visitor.fixup_scopes.push(vec![]);
+            let start_point = visitor.fixup_scopes.len();
             visitor.pessimistic_yield = true;
 
             // If the actual execution order turns out to be right-to-left,
@@ -1032,17 +1024,16 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
             // then we'll assign too low a count to any `yield` expressions
             // we encounter in 'right_expression' - they should really occur after all of the
             // expressions in 'left_expression'.
-            visitor.visit_expr(&right_expression);
-
+            visitor.visit_expr(&right_expr);
             visitor.pessimistic_yield = prev_pessimistic;
 
-            let target_scopes = visitor.fixup_scopes.pop().unwrap();
             debug!("resolve_expr - restoring pessimistic_yield to {}", prev_pessimistic);
-
-
-            visitor.visit_expr(&left_expression);
+            visitor.visit_expr(&left_expr);
             debug!("resolve_expr - fixing up counts to {}", visitor.expr_and_pat_count);
 
+            // Remove and process any scopes pushed by the visitor
+            let target_scopes = visitor.fixup_scopes.drain(start_point..);
+
             for scope in target_scopes {
                 let mut yield_data = visitor.scope_tree.yield_in_scope.get_mut(&scope).unwrap();
                 let count = yield_data.expr_and_pat_count;
@@ -1083,7 +1074,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
             visitor.scope_tree.yield_in_scope.insert(scope, data);
             if visitor.pessimistic_yield {
                 debug!("resolve_expr in pessimistic_yield - marking scope {:?} for fixup", scope);
-                visitor.fixup_scopes.last_mut().unwrap().push(scope);
+                visitor.fixup_scopes.push(scope);
             }
 
             // Keep traversing up while we can.
diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs
index d295c1f00c6..0bd078dace4 100644
--- a/src/librustc_typeck/check/generator_interior.rs
+++ b/src/librustc_typeck/check/generator_interior.rs
@@ -34,8 +34,6 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
 
         let live_across_yield = scope.map(|s| {
             self.region_scope_tree.yield_in_scope(s).and_then(|yield_data| {
-
-
                 // If we are recording an expression that is the last yield
                 // in the scope, or that has a postorder CFG index larger
                 // than the one of all of the yields, then its value can't