`for` loops are no longer closures.
This commit is contained in:
Shotaro Yamada 2019-01-03 23:20:44 +09:00
parent 6bae4a763d
commit 069b0c4108

View File

@ -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;
@ -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(||