about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2022-01-18 19:18:04 -0800
committerDavid Tolnay <dtolnay@gmail.com>2022-01-18 19:18:04 -0800
commit80139a0f02ef04dc759f47ad59ece2138117c41c (patch)
tree1d99e932cb403db160e18f2039e59da01d3a01ef
parentae28ec5a9c09b0ea163ccdff26b5650d4d0ea3c0 (diff)
downloadrust-80139a0f02ef04dc759f47ad59ece2138117c41c.tar.gz
rust-80139a0f02ef04dc759f47ad59ece2138117c41c.zip
Ensure Printer buf is always indexed using self.left or self.right
-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 e5542eda596..8d58eaa82a7 100644
--- a/compiler/rustc_ast_pretty/src/pp.rs
+++ b/compiler/rustc_ast_pretty/src/pp.rs
@@ -336,9 +336,9 @@ impl Printer {
 
     fn check_stream(&mut self) {
         if self.right_total - self.left_total > self.space {
-            if Some(&self.left) == self.scan_stack.back() {
-                let scanned = self.scan_stack.pop_back().unwrap();
-                self.buf[scanned].size = SIZE_INFINITY;
+            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 {