@@ -744,10 +744,13 @@ impl ExprCollector<'_> {
744
744
args : Box :: new ( [ self . collect_pat_top ( e. pat ( ) ) ] ) ,
745
745
ellipsis : None ,
746
746
} ;
747
+ let label = e. label ( ) . map ( |label| self . collect_label ( label) ) ;
747
748
let some_arm = MatchArm {
748
749
pat : self . alloc_pat_desugared ( some_pat) ,
749
750
guard : None ,
750
- expr : self . collect_expr_opt ( e. loop_body ( ) . map ( |x| x. into ( ) ) ) ,
751
+ expr : self . with_opt_labeled_rib ( label, |this| {
752
+ this. collect_expr_opt ( e. loop_body ( ) . map ( |x| x. into ( ) ) )
753
+ } ) ,
751
754
} ;
752
755
let iter_name = Name :: generate_new_name ( ) ;
753
756
let iter_binding = self . alloc_binding ( iter_name. clone ( ) , BindingAnnotation :: Mutable ) ;
@@ -769,7 +772,6 @@ impl ExprCollector<'_> {
769
772
Expr :: Match { expr : iter_next_expr, arms : Box :: new ( [ none_arm, some_arm] ) } ,
770
773
syntax_ptr. clone ( ) ,
771
774
) ;
772
- let label = e. label ( ) . map ( |label| self . collect_label ( label) ) ;
773
775
let loop_outer =
774
776
self . alloc_expr ( Expr :: Loop { body : loop_inner, label } , syntax_ptr. clone ( ) ) ;
775
777
let iter_pat = self . alloc_pat_desugared ( Pat :: Bind { id : iter_binding, subpat : None } ) ;
@@ -1426,6 +1428,17 @@ impl ExprCollector<'_> {
1426
1428
self . label_ribs . pop ( ) ;
1427
1429
res
1428
1430
}
1431
+
1432
+ fn with_opt_labeled_rib < T > (
1433
+ & mut self ,
1434
+ label : Option < LabelId > ,
1435
+ f : impl FnOnce ( & mut Self ) -> T ,
1436
+ ) -> T {
1437
+ match label {
1438
+ None => f ( self ) ,
1439
+ Some ( label) => self . with_labeled_rib ( label, f) ,
1440
+ }
1441
+ }
1429
1442
// endregion: labels
1430
1443
}
1431
1444
0 commit comments