@@ -326,17 +326,19 @@ impl<'a> LoweringContext<'a> {
326
326
o_id. map ( |sp_ident| respan ( sp_ident. span , sp_ident. node . name ) )
327
327
}
328
328
329
- fn lower_label ( & mut self , label : Option < ( NodeId , Spanned < Ident > ) > ) -> hir:: Label {
330
- match label {
331
- Some ( ( id, label_ident) ) => hir:: Label {
329
+ fn lower_destination ( & mut self , destination : Option < ( NodeId , Spanned < Ident > ) > )
330
+ -> hir:: Destination
331
+ {
332
+ match destination {
333
+ Some ( ( id, label_ident) ) => hir:: Destination {
332
334
ident : Some ( label_ident) ,
333
335
loop_id : if let Def :: Label ( loop_id) = self . expect_full_def ( id) {
334
336
hir:: LoopIdResult :: Ok ( loop_id)
335
337
} else {
336
338
hir:: LoopIdResult :: Err ( hir:: LoopIdError :: UnresolvedLabel )
337
339
}
338
340
} ,
339
- None => hir:: Label {
341
+ None => hir:: Destination {
340
342
ident : None ,
341
343
loop_id : self . loop_scopes . last ( ) . map ( |innermost_loop_id| Ok ( * innermost_loop_id) )
342
344
. unwrap_or ( Err ( hir:: LoopIdError :: OutsideLoopScope ) ) . into ( )
@@ -1729,12 +1731,12 @@ impl<'a> LoweringContext<'a> {
1729
1731
}
1730
1732
ExprKind :: Break ( opt_ident, ref opt_expr) => {
1731
1733
let label_result = if self . is_in_loop_condition && opt_ident. is_none ( ) {
1732
- hir:: Label {
1734
+ hir:: Destination {
1733
1735
ident : opt_ident,
1734
1736
loop_id : Err ( hir:: LoopIdError :: UnlabeledCfInWhileCondition ) . into ( ) ,
1735
1737
}
1736
1738
} else {
1737
- self . lower_label ( opt_ident. map ( |ident| ( e. id , ident) ) )
1739
+ self . lower_destination ( opt_ident. map ( |ident| ( e. id , ident) ) )
1738
1740
} ;
1739
1741
hir:: ExprBreak (
1740
1742
label_result,
@@ -1743,13 +1745,13 @@ impl<'a> LoweringContext<'a> {
1743
1745
ExprKind :: Continue ( opt_ident) =>
1744
1746
hir:: ExprAgain (
1745
1747
if self . is_in_loop_condition && opt_ident. is_none ( ) {
1746
- hir:: Label {
1748
+ hir:: Destination {
1747
1749
ident : opt_ident,
1748
1750
loop_id : Err (
1749
1751
hir:: LoopIdError :: UnlabeledCfInWhileCondition ) . into ( ) ,
1750
1752
}
1751
1753
} else {
1752
- self . lower_label ( opt_ident. map ( | ident| ( e. id , ident) ) )
1754
+ self . lower_destination ( opt_ident. map ( |ident| ( e. id , ident) ) )
1753
1755
} ) ,
1754
1756
ExprKind :: Ret ( ref e) => hir:: ExprRet ( e. as_ref ( ) . map ( |x| P ( self . lower_expr ( x) ) ) ) ,
1755
1757
ExprKind :: InlineAsm ( ref asm) => {
@@ -2244,7 +2246,7 @@ impl<'a> LoweringContext<'a> {
2244
2246
}
2245
2247
2246
2248
fn expr_break ( & mut self , span : Span , attrs : ThinVec < Attribute > ) -> P < hir:: Expr > {
2247
- let expr_break = hir:: ExprBreak ( self . lower_label ( None ) , None ) ;
2249
+ let expr_break = hir:: ExprBreak ( self . lower_destination ( None ) , None ) ;
2248
2250
P ( self . expr ( span, expr_break, attrs) )
2249
2251
}
2250
2252
0 commit comments