@@ -1156,7 +1156,7 @@ impl<'a> LoweringContext<'a> {
11561156 bounds. iter ( ) . map ( |bound| self . lower_ty_param_bound ( bound) ) . collect ( )
11571157 }
11581158
1159- fn lower_block ( & mut self , b : & Block , break_to : Option < NodeId > ) -> P < hir:: Block > {
1159+ fn lower_block ( & mut self , b : & Block , targeted_by_break : bool ) -> P < hir:: Block > {
11601160 let mut expr = None ;
11611161
11621162 let mut stmts = vec ! [ ] ;
@@ -1179,7 +1179,7 @@ impl<'a> LoweringContext<'a> {
11791179 expr : expr,
11801180 rules : self . lower_block_check_mode ( & b. rules ) ,
11811181 span : b. span ,
1182- break_to_expr_id : break_to ,
1182+ targeted_by_break : targeted_by_break ,
11831183 } )
11841184 }
11851185
@@ -1274,7 +1274,7 @@ impl<'a> LoweringContext<'a> {
12741274 }
12751275 ItemKind :: Fn ( ref decl, unsafety, constness, abi, ref generics, ref body) => {
12761276 self . with_new_scopes ( |this| {
1277- let body = this. lower_block ( body, None ) ;
1277+ let body = this. lower_block ( body, false ) ;
12781278 let body = this. expr_block ( body, ThinVec :: new ( ) ) ;
12791279 let body_id = this. record_body ( body, Some ( decl) ) ;
12801280 hir:: ItemFn ( this. lower_fn_decl ( decl) ,
@@ -1368,7 +1368,7 @@ impl<'a> LoweringContext<'a> {
13681368 hir:: TraitMethod :: Required ( names) )
13691369 }
13701370 TraitItemKind :: Method ( ref sig, Some ( ref body) ) => {
1371- let body = this. lower_block ( body, None ) ;
1371+ let body = this. lower_block ( body, false ) ;
13721372 let expr = this. expr_block ( body, ThinVec :: new ( ) ) ;
13731373 let body_id = this. record_body ( expr, Some ( & sig. decl ) ) ;
13741374 hir:: TraitItemKind :: Method ( this. lower_method_sig ( sig) ,
@@ -1424,7 +1424,7 @@ impl<'a> LoweringContext<'a> {
14241424 hir:: ImplItemKind :: Const ( this. lower_ty ( ty) , body_id)
14251425 }
14261426 ImplItemKind :: Method ( ref sig, ref body) => {
1427- let body = this. lower_block ( body, None ) ;
1427+ let body = this. lower_block ( body, false ) ;
14281428 let expr = this. expr_block ( body, ThinVec :: new ( ) ) ;
14291429 let body_id = this. record_body ( expr, Some ( & sig. decl ) ) ;
14301430 hir:: ImplItemKind :: Method ( this. lower_method_sig ( sig) , body_id)
@@ -1848,32 +1848,35 @@ impl<'a> LoweringContext<'a> {
18481848 id : id,
18491849 rules : hir:: DefaultBlock ,
18501850 span : span,
1851- break_to_expr_id : None ,
1851+ targeted_by_break : false ,
18521852 } ) ;
18531853 P ( self . expr_block ( blk, ThinVec :: new ( ) ) )
18541854 }
18551855 _ => P ( self . lower_expr ( els) ) ,
18561856 }
18571857 } ) ;
18581858
1859- hir:: ExprIf ( P ( self . lower_expr ( cond) ) , self . lower_block ( blk, None ) , else_opt)
1859+ let then_blk = self . lower_block ( blk, false ) ;
1860+ let then_expr = self . expr_block ( then_blk, ThinVec :: new ( ) ) ;
1861+
1862+ hir:: ExprIf ( P ( self . lower_expr ( cond) ) , P ( then_expr) , else_opt)
18601863 }
18611864 ExprKind :: While ( ref cond, ref body, opt_ident) => {
18621865 self . with_loop_scope ( e. id , |this|
18631866 hir:: ExprWhile (
18641867 this. with_loop_condition_scope ( |this| P ( this. lower_expr ( cond) ) ) ,
1865- this. lower_block ( body, None ) ,
1868+ this. lower_block ( body, false ) ,
18661869 this. lower_opt_sp_ident ( opt_ident) ) )
18671870 }
18681871 ExprKind :: Loop ( ref body, opt_ident) => {
18691872 self . with_loop_scope ( e. id , |this|
1870- hir:: ExprLoop ( this. lower_block ( body, None ) ,
1873+ hir:: ExprLoop ( this. lower_block ( body, false ) ,
18711874 this. lower_opt_sp_ident ( opt_ident) ,
18721875 hir:: LoopSource :: Loop ) )
18731876 }
18741877 ExprKind :: Catch ( ref body) => {
1875- self . with_catch_scope ( e . id , |this|
1876- hir:: ExprBlock ( this. lower_block ( body, Some ( e . id ) ) ) )
1878+ self . with_catch_scope ( body . id , |this|
1879+ hir:: ExprBlock ( this. lower_block ( body, true ) ) )
18771880 }
18781881 ExprKind :: Match ( ref expr, ref arms) => {
18791882 hir:: ExprMatch ( P ( self . lower_expr ( expr) ) ,
@@ -1891,7 +1894,7 @@ impl<'a> LoweringContext<'a> {
18911894 } )
18921895 } )
18931896 }
1894- ExprKind :: Block ( ref blk) => hir:: ExprBlock ( self . lower_block ( blk, None ) ) ,
1897+ ExprKind :: Block ( ref blk) => hir:: ExprBlock ( self . lower_block ( blk, false ) ) ,
18951898 ExprKind :: Assign ( ref el, ref er) => {
18961899 hir:: ExprAssign ( P ( self . lower_expr ( el) ) , P ( self . lower_expr ( er) ) )
18971900 }
@@ -2037,7 +2040,7 @@ impl<'a> LoweringContext<'a> {
20372040
20382041 // `<pat> => <body>`
20392042 {
2040- let body = self . lower_block ( body, None ) ;
2043+ let body = self . lower_block ( body, false ) ;
20412044 let body_expr = P ( self . expr_block ( body, ThinVec :: new ( ) ) ) ;
20422045 let pat = self . lower_pat ( pat) ;
20432046 arms. push ( self . arm ( hir_vec ! [ pat] , body_expr) ) ;
@@ -2109,7 +2112,7 @@ impl<'a> LoweringContext<'a> {
21092112 let ( guard, body) = if let ExprKind :: If ( ref cond,
21102113 ref then,
21112114 _) = else_expr. node {
2112- let then = self . lower_block ( then, None ) ;
2115+ let then = self . lower_block ( then, false ) ;
21132116 ( Some ( cond) ,
21142117 self . expr_block ( then, ThinVec :: new ( ) ) )
21152118 } else {
@@ -2159,7 +2162,7 @@ impl<'a> LoweringContext<'a> {
21592162 // Note that the block AND the condition are evaluated in the loop scope.
21602163 // This is done to allow `break` from inside the condition of the loop.
21612164 let ( body, break_expr, sub_expr) = self . with_loop_scope ( e. id , |this| (
2162- this. lower_block ( body, None ) ,
2165+ this. lower_block ( body, false ) ,
21632166 this. expr_break ( e. span , ThinVec :: new ( ) ) ,
21642167 this. with_loop_condition_scope ( |this| P ( this. lower_expr ( sub_expr) ) ) ,
21652168 ) ) ;
@@ -2220,7 +2223,7 @@ impl<'a> LoweringContext<'a> {
22202223 // `::std::option::Option::Some(<pat>) => <body>`
22212224 let pat_arm = {
22222225 let body_block = self . with_loop_scope ( e. id ,
2223- |this| this. lower_block ( body, None ) ) ;
2226+ |this| this. lower_block ( body, false ) ) ;
22242227 let body_expr = P ( self . expr_block ( body_block, ThinVec :: new ( ) ) ) ;
22252228 let pat = self . lower_pat ( pat) ;
22262229 let some_pat = self . pat_some ( e. span , pat) ;
@@ -2652,7 +2655,7 @@ impl<'a> LoweringContext<'a> {
26522655 id : self . next_id ( ) ,
26532656 rules : hir:: DefaultBlock ,
26542657 span : span,
2655- break_to_expr_id : None ,
2658+ targeted_by_break : false ,
26562659 }
26572660 }
26582661
@@ -2760,7 +2763,7 @@ impl<'a> LoweringContext<'a> {
27602763 id : id,
27612764 stmts : stmts,
27622765 expr : Some ( expr) ,
2763- break_to_expr_id : None ,
2766+ targeted_by_break : false ,
27642767 } ) ;
27652768 self . expr_block ( block, attrs)
27662769 }
0 commit comments