Navigation Menu

Skip to content

Commit

Permalink
Index a single time in check_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 19, 2022
1 parent a37d272 commit 377c9db
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/rustc_ast_pretty/src/pp.rs
Expand Up @@ -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;
}
Expand Down

0 comments on commit 377c9db

Please sign in to comment.