Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
`for` loops are no longer closures.
  • Loading branch information
sinkuu committed Jan 3, 2019
1 parent 6bae4a7 commit 069b0c4
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,17 +911,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}

fn compute(&mut self, body: &hir::Expr) -> LiveNode {
// if there is a `break` or `continue` at the top level, then it's
// effectively a return---this only occurs in `for` loops,
// where the body is really a closure.

debug!("compute: using id for body, {}", self.ir.tcx.hir().node_to_pretty_string(body.id));

let exit_ln = self.s.exit_ln;

self.break_ln.insert(body.id, exit_ln);
self.cont_ln.insert(body.id, exit_ln);

// the fallthrough exit is only for those cases where we do not
// explicitly return:
let s = self.s;
Expand Down Expand Up @@ -1024,19 +1015,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
self.propagate_through_expr(&e, succ)
}

hir::ExprKind::Closure(.., blk_id, _, _) => {
hir::ExprKind::Closure(..) => {
debug!("{} is an ExprKind::Closure",
self.ir.tcx.hir().node_to_pretty_string(expr.id));

// The next-node for a break is the successor of the entire
// loop. The next-node for a continue is the top of this loop.
let node = self.live_node(expr.hir_id, expr.span);

let break_ln = succ;
let cont_ln = node;
self.break_ln.insert(blk_id.node_id, break_ln);
self.cont_ln.insert(blk_id.node_id, cont_ln);

// the construction of a closure itself is not important,
// but we have to consider the closed over variables.
let caps = self.ir.capture_info_map.get(&expr.id).cloned().unwrap_or_else(||
Expand Down

0 comments on commit 069b0c4

Please sign in to comment.