@@ -911,17 +911,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
911
911
}
912
912
913
913
fn compute ( & mut self , body : & hir:: Expr ) -> LiveNode {
914
- // if there is a `break` or `again` at the top level, then it's
915
- // effectively a return---this only occurs in `for` loops,
916
- // where the body is really a closure.
917
-
918
914
debug ! ( "compute: using id for body, {}" , self . ir. tcx. hir( ) . node_to_pretty_string( body. id) ) ;
919
915
920
- let exit_ln = self . s . exit_ln ;
921
-
922
- self . break_ln . insert ( body. id , exit_ln) ;
923
- self . cont_ln . insert ( body. id , exit_ln) ;
924
-
925
916
// the fallthrough exit is only for those cases where we do not
926
917
// explicitly return:
927
918
let s = self . s ;
@@ -1024,19 +1015,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
1024
1015
self . propagate_through_expr ( & e, succ)
1025
1016
}
1026
1017
1027
- hir:: ExprKind :: Closure ( .., blk_id , _ , _ ) => {
1018
+ hir:: ExprKind :: Closure ( ..) => {
1028
1019
debug ! ( "{} is an ExprKind::Closure" ,
1029
1020
self . ir. tcx. hir( ) . node_to_pretty_string( expr. id) ) ;
1030
1021
1031
- // The next-node for a break is the successor of the entire
1032
- // loop. The next-node for a continue is the top of this loop.
1033
- let node = self . live_node ( expr. hir_id , expr. span ) ;
1034
-
1035
- let break_ln = succ;
1036
- let cont_ln = node;
1037
- self . break_ln . insert ( blk_id. node_id , break_ln) ;
1038
- self . cont_ln . insert ( blk_id. node_id , cont_ln) ;
1039
-
1040
1022
// the construction of a closure itself is not important,
1041
1023
// but we have to consider the closed over variables.
1042
1024
let caps = self . ir . capture_info_map . get ( & expr. id ) . cloned ( ) . unwrap_or_else ( ||
@@ -1407,15 +1389,16 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
1407
1389
debug ! ( "propagate_through_loop: using id for loop body {} {}" ,
1408
1390
expr. id, self . ir. tcx. hir( ) . node_to_pretty_string( body. id) ) ;
1409
1391
1410
- let break_ln = succ;
1411
- let cont_ln = ln;
1412
- self . break_ln . insert ( expr. id , break_ln) ;
1413
- self . cont_ln . insert ( expr. id , cont_ln) ;
1392
+
1393
+ self . break_ln . insert ( expr. id , succ) ;
1414
1394
1415
1395
let cond_ln = match kind {
1416
1396
LoopLoop => ln,
1417
1397
WhileLoop ( ref cond) => self . propagate_through_expr ( & cond, ln) ,
1418
1398
} ;
1399
+
1400
+ self . cont_ln . insert ( expr. id , cond_ln) ;
1401
+
1419
1402
let body_ln = self . propagate_through_block ( body, cond_ln) ;
1420
1403
1421
1404
// repeat until fixed point is reached:
0 commit comments