@@ -753,10 +753,13 @@ impl ExprCollector<'_> {
753
753
args : Box :: new ( [ self . collect_pat_top ( e. pat ( ) ) ] ) ,
754
754
ellipsis : None ,
755
755
} ;
756
+ let label = e. label ( ) . map ( |label| self . collect_label ( label) ) ;
756
757
let some_arm = MatchArm {
757
758
pat : self . alloc_pat_desugared ( some_pat) ,
758
759
guard : None ,
759
- expr : self . collect_expr_opt ( e. loop_body ( ) . map ( |x| x. into ( ) ) ) ,
760
+ expr : self . with_opt_labeled_rib ( label, |this| {
761
+ this. collect_expr_opt ( e. loop_body ( ) . map ( |x| x. into ( ) ) )
762
+ } ) ,
760
763
} ;
761
764
let iter_name = Name :: generate_new_name ( ) ;
762
765
let iter_binding = self . alloc_binding ( iter_name. clone ( ) , BindingAnnotation :: Mutable ) ;
@@ -778,7 +781,6 @@ impl ExprCollector<'_> {
778
781
Expr :: Match { expr : iter_next_expr, arms : Box :: new ( [ none_arm, some_arm] ) } ,
779
782
syntax_ptr. clone ( ) ,
780
783
) ;
781
- let label = e. label ( ) . map ( |label| self . collect_label ( label) ) ;
782
784
let loop_outer =
783
785
self . alloc_expr ( Expr :: Loop { body : loop_inner, label } , syntax_ptr. clone ( ) ) ;
784
786
let iter_pat = self . alloc_pat_desugared ( Pat :: Bind { id : iter_binding, subpat : None } ) ;
@@ -1449,6 +1451,17 @@ impl ExprCollector<'_> {
1449
1451
self . label_ribs . pop ( ) ;
1450
1452
res
1451
1453
}
1454
+
1455
+ fn with_opt_labeled_rib < T > (
1456
+ & mut self ,
1457
+ label : Option < LabelId > ,
1458
+ f : impl FnOnce ( & mut Self ) -> T ,
1459
+ ) -> T {
1460
+ match label {
1461
+ None => f ( self ) ,
1462
+ Some ( label) => self . with_labeled_rib ( label, f) ,
1463
+ }
1464
+ }
1452
1465
// endregion: labels
1453
1466
}
1454
1467
0 commit comments