Skip to content

Commit 377c9db

Browse files
committed
Index a single time in check_stack
1 parent a37d272 commit 377c9db

File tree

1 file changed

+5
-4
lines changed
  • compiler/rustc_ast_pretty/src

1 file changed

+5
-4
lines changed

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,25 @@ impl Printer {
380380

381381
fn check_stack(&mut self, mut k: usize) {
382382
while let Some(&x) = self.scan_stack.front() {
383-
match self.buf[x].token {
383+
let mut entry = &mut self.buf[x];
384+
match entry.token {
384385
Token::Begin(_) => {
385386
if k == 0 {
386387
break;
387388
}
388389
self.scan_stack.pop_front().unwrap();
389-
self.buf[x].size += self.right_total;
390+
entry.size += self.right_total;
390391
k -= 1;
391392
}
392393
Token::End => {
393394
// paper says + not =, but that makes no sense.
394395
self.scan_stack.pop_front().unwrap();
395-
self.buf[x].size = 1;
396+
entry.size = 1;
396397
k += 1;
397398
}
398399
_ => {
399400
self.scan_stack.pop_front().unwrap();
400-
self.buf[x].size += self.right_total;
401+
entry.size += self.right_total;
401402
if k == 0 {
402403
break;
403404
}

0 commit comments

Comments
 (0)