about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2022-01-18 19:19:18 -0800
committerDavid Tolnay <dtolnay@gmail.com>2022-01-18 19:19:18 -0800
commit0490e43422b3061ba3afef9b064a9360871d1455 (patch)
treef960297f0595bf1a119e997ce8681e96948c7ad7
parent947a09a4a88f97aa0ab59a5d21afd8ca3d429e60 (diff)
downloadrust-0490e43422b3061ba3afef9b064a9360871d1455.tar.gz
rust-0490e43422b3061ba3afef9b064a9360871d1455.zip
Implement check_stream nonrecursively
-rw-r--r--compiler/rustc_ast_pretty/src/pp.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs
index b2870ac2734..d32cc4694d3 100644
--- a/compiler/rustc_ast_pretty/src/pp.rs
+++ b/compiler/rustc_ast_pretty/src/pp.rs
@@ -335,14 +335,14 @@ impl Printer {
     }
 
     fn check_stream(&mut self) {
-        if self.right_total - self.left_total > self.space {
+        while self.right_total - self.left_total > self.space {
             if self.scan_stack.back() == Some(&self.left) {
                 self.scan_stack.pop_back().unwrap();
                 self.buf[self.left].size = SIZE_INFINITY;
             }
             self.advance_left();
-            if self.left != self.right {
-                self.check_stream();
+            if self.left == self.right {
+                break;
             }
         }
     }