From 8df498be1c08bb4a5c6317ef0a5802c362ba26ac Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 2 Aug 2018 15:30:57 -0500 Subject: [PATCH] more fixes for everybody_loops --- src/librustc_driver/pretty.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 1e74ae10403a8..2777593b6bd66 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -666,8 +666,10 @@ impl<'a> ReplaceBodyWithLoop<'a> { fn run R>(&mut self, is_const: bool, action: F) -> R { let old_const = mem::replace(&mut self.within_static_or_const, is_const); + let old_blocks = self.nested_blocks.take(); let ret = action(self); self.within_static_or_const = old_const; + self.nested_blocks = old_blocks; ret } @@ -745,6 +747,10 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { self.run(is_const, |s| fold::noop_fold_impl_item(i, s)) } + fn fold_anon_const(&mut self, c: ast::AnonConst) -> ast::AnonConst { + self.run(true, |s| fold::noop_fold_anon_const(c, s)) + } + fn fold_block(&mut self, b: P) -> P { fn stmt_to_block(rules: ast::BlockCheckMode, recovered: bool, @@ -811,7 +817,9 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { if let Some(old_blocks) = self.nested_blocks.as_mut() { //push our fresh block onto the cache and yield an empty block with `loop {}` - old_blocks.push(new_block); + if !new_block.stmts.is_empty() { + old_blocks.push(new_block); + } stmt_to_block(b.rules, b.recovered, Some(loop_stmt), self.sess) } else {