From 377c9dbabfe6574ff0161f0fd8e750bb57181530 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 18 Jan 2022 19:21:18 -0800 Subject: [PATCH] Index a single time in check_stack --- compiler/rustc_ast_pretty/src/pp.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index dca0515a330..d9832d560a8 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -380,24 +380,25 @@ impl Printer { fn check_stack(&mut self, mut k: usize) { while let Some(&x) = self.scan_stack.front() { - match self.buf[x].token { + let mut entry = &mut self.buf[x]; + match entry.token { Token::Begin(_) => { if k == 0 { break; } self.scan_stack.pop_front().unwrap(); - self.buf[x].size += self.right_total; + entry.size += self.right_total; k -= 1; } Token::End => { // paper says + not =, but that makes no sense. self.scan_stack.pop_front().unwrap(); - self.buf[x].size = 1; + entry.size = 1; k += 1; } _ => { self.scan_stack.pop_front().unwrap(); - self.buf[x].size += self.right_total; + entry.size += self.right_total; if k == 0 { break; }