@@ -666,8 +666,10 @@ impl<'a> ReplaceBodyWithLoop<'a> {
666
666
667
667
fn run < R , F : FnOnce ( & mut Self ) -> R > ( & mut self , is_const : bool , action : F ) -> R {
668
668
let old_const = mem:: replace ( & mut self . within_static_or_const , is_const) ;
669
+ let old_blocks = self . nested_blocks . take ( ) ;
669
670
let ret = action ( self ) ;
670
671
self . within_static_or_const = old_const;
672
+ self . nested_blocks = old_blocks;
671
673
ret
672
674
}
673
675
@@ -745,6 +747,10 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
745
747
self . run ( is_const, |s| fold:: noop_fold_impl_item ( i, s) )
746
748
}
747
749
750
+ fn fold_anon_const ( & mut self , c : ast:: AnonConst ) -> ast:: AnonConst {
751
+ self . run ( true , |s| fold:: noop_fold_anon_const ( c, s) )
752
+ }
753
+
748
754
fn fold_block ( & mut self , b : P < ast:: Block > ) -> P < ast:: Block > {
749
755
fn stmt_to_block ( rules : ast:: BlockCheckMode ,
750
756
recovered : bool ,
@@ -811,7 +817,9 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
811
817
812
818
if let Some ( old_blocks) = self . nested_blocks . as_mut ( ) {
813
819
//push our fresh block onto the cache and yield an empty block with `loop {}`
814
- old_blocks. push ( new_block) ;
820
+ if !new_block. stmts . is_empty ( ) {
821
+ old_blocks. push ( new_block) ;
822
+ }
815
823
816
824
stmt_to_block ( b. rules , b. recovered , Some ( loop_stmt) , self . sess )
817
825
} else {
0 commit comments